Use Load method in XmlDocument to load xml document : XmlDocument « XML « C# / C Sharp

Use Load method in XmlDocument to load xml document


<?xml version="1.0" ?>
<ord:order xmlns:ord="http://mycompany/OrderML"


    <ord:orderItem itemNumber="3211"/>
    <ord:orderItem itemNumber="1155"/>

using System;
using System.Xml;

class MainClass {
    public static void Main() {
        XmlDocument doc = new XmlDocument();

        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

1.A Simple XML Example
3.Save, AppendChild, CreateXmlDeclaration, CreateElement
4.Call GetElementsByTagName to get an element
5.Use SelectNodes to query nodes by XPath
6.Get XML Nodes in a Specific XML Namespace
7.Find Elements with an XPath Search
8.Add XmlElement
9.Load With Includes
10.Non CData Normalize