<?xml version="1.0" encoding="UTF-8" ?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns="http://www.monternet.com/dsmp/schemas/"><SOAP-ENV:Header>
<TransactionID xmlns="http://www.monternet.com/dsmp/schemas/" xsi:type="xsd:string">00140301801050</TransactionID> 
</SOAP-ENV:Header><SOAP-ENV:Body>
<UnSubscribeServiceResp xmlns="http://www.monternet.com/dsmp/schemas/">
<Version>1.5.0</Version>
<MsgType>UnSubscribeServiceResp</MsgType>
<hRet>115</hRet>
</UnSubscribeServiceResp>
</SOAP-ENV:Body></SOAP-ENV:Envelope>以上是XML文件问题:如何取得<hRet>节点的值?

解决方案 »

  1.   

    读的sample,自己看下.
    XmlDocument xmldoc = new XmlDocument();
    String tempstr1 = Path.Combine(Server.MapPath("."),"xml");
    String xmlPath = Path.Combine(tempstr1,"news_subject.xml");
    xmldoc.Load(xmlPath);
    XmlNodeList NdList = xmldoc.SelectNodes("NewsSubject/subject");
    for(int i=0;i<NdList.Count;i++)
    {
    String lm_id = NdList[i].SelectSingleNode("lm_id").InnerXml.Trim();
    String lm_name = "";
         lm_name = NdList[i].SelectSingleNode("lm_name").InnerXml.Trim();
    Response.Write(lm_name+"<br>"+lm_id+"<br>");
    }
      

  2.   

    xml的结构,自己看这个例子改把.
    <?xml version="1.0" encoding="gb2312"?>
    <NewsSubject>
      <subject>
        <lm_id>1</lm_id>
        <lm_name>人物0</lm_name>
      </subject>
      <subject>
        <lm_id>2</lm_id>
        <lm_name>春运1</lm_name>
      </subject>
      <subject>
        <lm_id>3</lm_id>
        <lm_name>地方撒法。</lm_name>
      </subject>
    </NewsSubject>
      

  3.   

    你这段XML文件不是well formed.
      

  4.   

    <?xml version="1.0" encoding="UTF-8" ?>
    <bookstore>
      <book ISBN="2-3631-4">
        <title>Oberon's Legacy</title>
        <author>Corets, Eva</author>
        <price>5.95</price>
      </book>
      <store>
        <a>123</a>
        <b>456</b>
      </store>
    </bookstore>
    代码如下(取a节点的值):
    Dim xmlDoc As New XmlDocument
            xmlDoc.Load("C:\test.xml")        Dim nodeList As XmlNodeList = xmlDoc.SelectSingleNode("bookstore").ChildNodes  '获取根节点下的所有子节点        Dim xn As XmlNode
            For Each xn In nodeList
                Dim xe As XmlElement = CType(xn, XmlElement)            Dim nls As XmlNodeList = xe.ChildNodes '继续获取xe子节点下的子节点
                Dim xn1 As XmlNode
                For Each xn1 In nls
                    Dim xe2 As XmlElement = CType(xn1, XmlElement)
                    If xe2.Name = "a" Then
                        Me.TextBox1.Text = xe2.InnerText
                        Exit For
                    End If
                Next
            Next
      

  5.   

    各位大侠再帮帮忙!拜谢!出错信息:未将对象引用设置到对象的实例。以下是代码://该returnValue的值就是获得xml字符串(内容见楼顶)
    returnValue = PostXmlAndGetResponse(postToUrl,xmlBody);

    XmlDocument doc = new XmlDocument();
    doc.LoadXml(returnValue);XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable);
    nsmgr.AddNamespace("SOAP-ENV","http://schemas.xmlsoap.org/soap/envelope/");

    XmlNode node = doc.SelectSingleNode("SOAP-ENV:Envelope/SOAP-ENV:Body/UnSubscribeServiceResp/hRet",nsmgr);
    string s = node.InnerText;if (s == "0")
    Response.Write("退订成功!");
    else
    Response.Write("退订不成功:错误代码:" + s);哪里错了?在线等!等!等!