如何获取xmlhttp请求返回xml数据节点的值
通过xmlhttp请求http://xxx/xxx.jsp返回结果为
<?xml version="1.0" encoding="GBK" ?>
<info>
<user>xxx</user>
<result>1</result>
</info>
请高手指点,如何获取result节点的值呢?
自己从网上找资料写了如下代码:
using MSXML2; protected void Page_Load(object sender, EventArgs e) { MSXML2.XMLHTTPClass x = new XMLHTTPClass(); MSXML2.DOMDocument40 xmlDom= new DOMDocument40(); try { x.open("Post", "http://xxx/xxx.jsp", false, "", ""); x.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); x.send(""); } finally { if (x.status / 100 == 2) { xmlDom.loadXML(x.responseXML.ToString()); //这里报错 } } Response.Write(xmlDom.selectSingleNode("/info/result").text); }