<?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>节点的值?
<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>节点的值?
解决方案 »
- asp.net 调用其它页面遇到的命名空间问题?急
- 请问ass name 和 add key 这2种连接方式有什么区别?
- 懂数据岛技术的同志进来帮帮忙,没分了,多多照顾
- 在前台代码中怎么修改后台变量的值?
- :《ASP.NET 入门经典——C# 编程篇 的问题,请问如何下载源代码?
- GridView显示无限级分类
- ★★★★急!SQL 2000小问题★★★
- 怎样在用Input File控件选择完文件后只取文件路径而不上传文件?
- 为什么在ASP.NET页面中传递中文时出现乱码?
- saucer 进来,刚才关于Forms认证方式的帖子给错分了,快进来受分
- 如何再Module里得到当前程序路径?
- 大问题!好难啊!穷鬼提问有没人理会?有耐性的朋友帮我看看好吗?
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>");
}
<?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>
<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
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);哪里错了?在线等!等!等!