I am trying to retrieve the Parameters first or second (0, 1 ,2) node from
the following XML file:
<?xml version="1.0" encoding="utf-8" ?>
<Robot xmlns="http://tempuri.org/RobotDefaults.xsd">
<Parameters>
<Name>Decker</Name>
</Parameters>
<Parameters>
<Name>A</Name>
</Parameters>
<Parameters>
<Name>B</Name>
</Parameters>
</Robot>
There will be more data than just a name for each Parameters node. Here is
my code:
Dim node As XmlNode = xmlDocument.SelectSingleNode("/Parameters")
RobotName.Text = node.SelectSingleNode("Name").InnerText
I get the dreaded "Object reference not set to an instance of an object."
The SelectSingleNode is not working because I am too dense to figure out how
to write the syntax for the XPAth. I have read the documentation all morning
and am still having trouble.
I have downloaded really nice software called VisualXPath and tried this
query string from it:
/def:Robot/def:Parameters[1]
This gets me a "System Error"
Can anybody show me how to retrieve the "x" number Parameter node from this
document?
Thanks,
Eric