如何使用SelectSingleNode获取OverallResult元素的innertext?
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<ProcessResp xmlns="http://www.w3.org/2005/Atom">
<Result>
<OverallResult>Success</OverallResult>
答案 0 :(得分:0)
var doc = new XmlDocument();
doc.LoadXml(xml);
var text = doc.SelectSingleNode("Example/Node/text()").InnerText; // or .Value
返回
"Some text here\r\n "
和text.Trim()返回
"Some text here"
请通过以下链接查看与XML相关的查询,这对于初学者非常有用!
http://www.dotnetcurry.com/ShowArticle.aspx?ID=564
为你的答案(我试过尝试,但尝试通过你的代码改变这样)
doc.SelectSingleNode("soap/ProcessResp/ Result/OverallResult/text()").InnerText;