XmlDocument-应用两例

作者:vkvi 来源:ITPOW(原创) 日期:2010-9-18

SelectNodes

System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.Load(Server.MapPath("~/App_Data/Navigator.xml"));
System.Xml.XmlNodeList nodes = doc.SelectNodes("/navigator/item");
for (int i = 0; i < nodes.Count; i++)
{
    string title = nodes[i].Attributes["title"].Value;
    // ...
}

SelectSingleNode

System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.LoadXml(xmlString);
string docTitle = doc.SelectSingleNode("//docTitle").InnerText;

相关阅读

相关文章