Use Load method in XmlDocument to load xml document
//Order.xml
/*
<?xml version="1.0" ?>
<ord:order xmlns:ord="http://mycompany/OrderML"
xmlns:cli="http://mycompany/ClientML">
<cli:client>
<cli:firstName>Sally</cli:firstName>
<cli:lastName>Sergeyeva</cli:lastName>
</cli:client>
<ord:orderItem itemNumber="3211"/>
<ord:orderItem itemNumber="1155"/>
</ord:order>
*/
using System;
using System.Xml;
class MainClass {
public static void Main() {
XmlDocument doc = new XmlDocument();
doc.Load("Order.xml");
XmlNodeList matches = doc.GetElementsByTagName("*", "http://mycompany/OrderML");
foreach (XmlNode node in matches) {
Console.Write(node.Name + "\t");
foreach (XmlAttribute attribute in node.Attributes) {
Console.Write(attribute.Value + " ");
}
}
}
}
Related examples in the same category