M
Mark Fox
Hello,
I have some XML loaded into an XmlDocument and
attempting to figure out how to access certain nodes. I
assume I should use XPath, but I am having trouble
getting the XPath syntax correct. Where might I be going
wrong? Any help would be appreciated!
XML:
<Reason>
<ReasonCategory>Death</ReasonCategory>
<Contacts>
<Contact>
<Name></Name>
<Phone></Phone>
<Address></Address>
<CityStateZip></CityStateZip>
<Relation></Relation>
<IsMember></IsMember>
</Contact>
</Contacts>
<ReasonDetails>
<PlaceOfDeath></PlaceOfDeath>
<CauseOfDeath></CauseOfDeath>
<FuneralLocationName></FuneralLocationName>
<FuneralDateTime></FuneralDateTime>
<ReasonDetails>
<RequestedServices>
<RequestedService>
<OfferedServiceName></OfferedServiceName>
<AssignedTo></AssignedTo>
</RequestedService>
</RequestedServices>
<FormDetails>
<CompletedBy></CompletedBy>
<CompletedDate></CompletedDate>
<Notes></Notes>
</FormDetails>
</Reason>
I am attempting to access the ReasonCategory node with:
XmlNodeReader myXmlNodeReader = new XmlNodeReader
(myXmlDocument.SelectSingleNode("Reason/ReasonCategory"));
string ReasonCategory =
myXmlNodeReader.Value;
But the XmlNodeReader isn't finding the node. Thanks for
your help!
I have some XML loaded into an XmlDocument and
attempting to figure out how to access certain nodes. I
assume I should use XPath, but I am having trouble
getting the XPath syntax correct. Where might I be going
wrong? Any help would be appreciated!
XML:
<Reason>
<ReasonCategory>Death</ReasonCategory>
<Contacts>
<Contact>
<Name></Name>
<Phone></Phone>
<Address></Address>
<CityStateZip></CityStateZip>
<Relation></Relation>
<IsMember></IsMember>
</Contact>
</Contacts>
<ReasonDetails>
<PlaceOfDeath></PlaceOfDeath>
<CauseOfDeath></CauseOfDeath>
<FuneralLocationName></FuneralLocationName>
<FuneralDateTime></FuneralDateTime>
<ReasonDetails>
<RequestedServices>
<RequestedService>
<OfferedServiceName></OfferedServiceName>
<AssignedTo></AssignedTo>
</RequestedService>
</RequestedServices>
<FormDetails>
<CompletedBy></CompletedBy>
<CompletedDate></CompletedDate>
<Notes></Notes>
</FormDetails>
</Reason>
I am attempting to access the ReasonCategory node with:
XmlNodeReader myXmlNodeReader = new XmlNodeReader
(myXmlDocument.SelectSingleNode("Reason/ReasonCategory"));
string ReasonCategory =
myXmlNodeReader.Value;
But the XmlNodeReader isn't finding the node. Thanks for
your help!