閱讀734 返回首頁    go 阿裏雲 go 技術社區[雲棲]


獲取Xml中指定子節點值

待處理的Xml文件:
<?xml version="1.0" encoding='UTF-8'?>
<ufinterface billtype="gl" filename="gledi" isexchange="Y" proc="add" receiver="01" replace="Y" roottag="sendresult" sender="ceec" successful="Y">
	<sendresult>
		<billpk>
		</billpk>
		<bdocid>AAAA</bdocid>
		<filename>BBBB</filename>
		<resultcode>CCCC</resultcode>
		<resultdescription>DDDD</resultdescription>
		<content>EEEE</content>
	</sendresult>
	<sendresult>
		<billpk>
		</billpk>
		<bdocid>aaaa</bdocid>
		<filename>bbbb</filename>
		<resultcode>cccc</resultcode>
		<resultdescription>dddd</resultdescription>
		<content>eeee</content>
	</sendresult>
</ufinterface>
//獲取<sendresult>節點下<bdocid>與<resultdescription>的值

XmlDocument Xd = new XmlDocument();
Xd.Load("E:\\Books.xml");
XmlNode Sroot = Xd.SelectSingleNode("//sendresult");
Pzbh = (Sroot.SelectSingleNode("bdocid")).InnerText;
Djxx = (Sroot.SelectSingleNode("resultdescription")).InnerText;


最後更新:2017-04-03 12:54:19

  上一篇:go C# POST XML(修正中文亂碼問題)
  下一篇:go win7遠程桌麵連接如何設置