Why does this XPath return a result in XPath Tester, but not in my code? I think that I'm overlooking something simple.
Sub Main()
Dim doc As New XmlDocument()
doc.Load(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile)
Dim xmlNode As XmlElement = TryCast(doc.SelectSingleNode("/configuration/Status"), XmlElement)
Dim xpath = "/Status/ElementOne[@ID='1234']"
Console.WriteLine(xmlNode.OuterXml)
Console.WriteLine()
Console.WriteLine(xpath)
Dim eFileEvent = xmlNode.SelectSingleNode(xpath)
Console.WriteLine()
Console.WriteLine("Results")
If (eFileEvent Is Nothing) Then
Return
End If
Console.WriteLine(eFileEvent.OuterXml)
End Sub
Config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
...
<configSections>
<section name="Status" type="System.Configuration.IgnoreSectionHandler, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowLocation="false" />
</configSections>
<Status xmlns="">
<ElementOne ID="1234"></ElementOne>
</Status>
</configuration>