I am trying to return the value of certain attributes in an XML file and for some reason I cannot do it.
I load the XML document and select the node from the path:
XmlDocument doc = new XmlDocument();
doc.Load(@"XMLDocument.xml");
XmlNode dataAttribute = doc.SelectSingleNode(@"/ProcessCustomerPartyMaster/ApplicationArea/Sender/UserArea/Property/NameValue[@name='websiteurl']");
The XML document:
<?xml version="1.0" encoding="utf-16"?>
<ProcessCustomerPartyMaster xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" languageCode="en-US" systemEnvironmentCode="" versionID="0" releaseID="2"
xmlns="http://schema.infor.com/InforOAGIS/2">
<ApplicationArea>
<Sender>
<UserArea>
<Property>
<NameValue type="StringType" name="cr12d_legacy" />
</Property>
<Property>
<NameValue type="StringType" name="SALN05" />
</Property>
<Property>
<NameValue type="StringType" name="websiteurl">https://www.davis.com</NameValue>
</Property>
</UserArea>
</Sender>
</ApplicationArea>
</ProcessCustomerPartyMaster>
As an example, what would I need to do to pull the value from the NameValue
where name='websiteurl'
?
Edit I have already tried bypassing the namespaces by using
XmlNode dataAttribute = doc.SelectSingleNode(@"/*[local-name()='NameValue']");