using System; using System.IO; using System.Xml;public class Sample { public static void Main() { XmlDocument doc = new XmlDocument(); string xml=@"<?xml version='1.0' encoding='gb2312' ?> <words> <word c='中文' e='english' /> </words>"; doc.LoadXML(xml); //Create an XmlNamespaceManager for resolving namespaces. XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable); nsmgr.AddNamespace("bk", "urn:samples"); //Select and display the value of all the ISBN attributes. XmlNodeList nodeList; XmlElement root = doc.DocumentElement; nodeList = root.SelectNodes("/bookstore/book/@bk:ISBN", nsmgr); foreach (XmlNode isbn in nodeList){ Console.WriteLine(isbn.Value); } }}
using System.IO;
using System.Xml;public class Sample
{
public static void Main()
{ XmlDocument doc = new XmlDocument();
string xml=@"<?xml version='1.0' encoding='gb2312' ?>
<words>
<word c='中文' e='english' />
</words>";
doc.LoadXML(xml); //Create an XmlNamespaceManager for resolving namespaces.
XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable);
nsmgr.AddNamespace("bk", "urn:samples"); //Select and display the value of all the ISBN attributes.
XmlNodeList nodeList;
XmlElement root = doc.DocumentElement;
nodeList = root.SelectNodes("/bookstore/book/@bk:ISBN", nsmgr);
foreach (XmlNode isbn in nodeList){
Console.WriteLine(isbn.Value);
} }}