All pastes #728960 Raw Edit

Something

public text v1 · immutable
·published 2007-10-07 15:08 UTC
rendered paste body
/*
Assuming you have an XML file that's like this:

<library>
    <books>
        <book>
            <book-name>Hello World: The Ultimate Manual</book-name>
        </book>
    </books>
</library>
*/

using System.Xml;

void DoXmlStuff ()
{
    XmlDocument doc = new XmlDocument ();
    try {
        doc.Load ("/tmp/myxmlfile.xml");
    } catch (Exception e) {
        Console.WriteLine ("something bad happened");
        return;
    }

    XmlNode node = doc.SelectSingleNode ("book-name");
    if (node != null) {
        string bookName = node.InnerText;
        Console.WriteLine ("The book name is: {0}", bookName);
    }
}