阅读XML子元素 [英] reading XML Child Elements
本文介绍了阅读XML子元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好朋友,
这是我的XML文件,我有两个子元素.其中,我需要读取任何一个特定元素及其内部元素类型,任何一个都可以帮助我.
Hello Friends,
This is my XML file i had two child elements.among them i need to read any only one particular element and its inner elements type, can any one help me.
<?xml version="1.0" encoding="utf-8" ?><big></big>
<appSettings>
<mail>
<add key="ColourOrange" value="" type="URL"/>
<add key="SMTP_Port" value="" type="URL"/>
</mail>
<map>
<add key="MapCenterX" value="" type="NUMERIC"/>
<add key="MapCenterY" value="" type="NUMERIC"/>
<add key="Radius" value="" type="NUMERIC"/>
</map>
</appSettings>
推荐答案
XmlDocument xDoc = new XmlDocument();
xDoc.Load(yourXMLDocumentPath);
XmlNode oneNode = xDoc.SelectSingleNode("appSettings/mail"); // or whatever else
foreach(XmlNode iNode in oneNode.ChildNodes) {
// scan your <mail> element or whatever else
}
请参阅类似的 ^ ]
如果问题是要获取appSettings,请阅读此文章> Custom-Configuration-Sections-for-Lazy-Coders
if the problem is to get appSettings, read this article Custom-Configuration-Sections-for-Lazy-Coders
这篇关于阅读XML子元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文