I have programmed in VB6 and VC but I am new to C# and XML and I can't seem to muddle my way through the simplest of problems. Given an XML file below, I just want to know what the value of PI is. Why doesn't this work? N = root.SelectSingleNode("descendant::variable[name='PI']"); Debug.Print(N.InnerText); Thanks for listening. Tom XML File: <?xml version="1.0"?> <!-- Simple test XML file --> <bookstore xmlns:bk="urn:samples"> <Variables> <Variable name="PI"> 3.1415926535 </Variable> <Variable name="Four"> 4 </Variable> </Variables> </bookstore>
Eventually found the answer. For anyone else stuck on this: XmlNode N; string sVariable; N = root.SelectSingleNode("//descendant::variable[name='pi']/value"); if (N != null) { sVariable = N.InnerText; Debug.Print(sVariable); } Tom