Hi,
I'm trying to extract data from objects that contain xml that fits a
third party schema with it's own root namespace. I've added a
namespace manager that seemed to work most of the time but I never
fully understood why. I've now hit another problem. It might be code
blindness but I can't see why it doesn't work.
I am trying to select a node using XPath from an XmlElement
XmlElement xEntityNode ;
/* xEntityNode's OuterXml is this
<facilityList xmlns="qvEntityTypes">
<facility>
<internalId>6</internalId>
<description>OrderOnLine</description>
<displayOrder>1</displayOrder>
</facility>
<facility>
<internalId>7</internalId>
<description>ConfirmHeldOrders</description>
<displayOrder>1</displayOrder>
</facility>
<facility>
<internalId>28</internalId>
<description>ViewProductStock</description>
<displayOrder>1</displayOrder>
</facility>
<facility>
<internalId>29</internalId>
<description>SeeOtherUsersOrders</description>
<displayOrder>1</displayOrder>
</facility>
<facility>
<internalId>30</internalId>
<description>Buy</description>
<displayOrder>1</displayOrder>
</facility>
</facilityList>
*/
// Here's my code
nsmgr = new XmlNamespaceManager( new System.Xml.NameTable() );
nsmgr.AddNamespace("qv", "qvEntityTypes") ;
XmlNode propertyNode = xEntityNode.SelectSingleNode(
"//qv:facilityList/qv:facility[description = \"Buy\"]" , nsmgr);
// END
SelectSingleNode returns null. I think the namespace applies to the
nested facility level hence the qv:facility.
Can anyone suggest a better way of dealing with the namespace?