XPath doesn't work as desired in C#

Posted by Nick Brooks on Stack Overflow See other posts from Stack Overflow or by Nick Brooks
Published on 2010-04-04T21:54:05Z Indexed on 2010/04/04 22:03 UTC
Read the original article Hit count: 594

Filed under:
|
|

My code doesn't return the node

XmlDocument xml = new XmlDocument();
xml.InnerXml = text;

XmlNode node_ =  xml.SelectSingleNode(node);
return node_.InnerText; // node_ = null !!!!!!!!!!!!!!!!!!!

I'm pretty sure my XML and Xpath are correct

My Xpath : /ItemLookupResponse/OperationRequest/RequestId'

My XML :

<?xml version="1.0"?>
<ItemLookupResponse xmlns="http://webservices.amazon.com/AWSECommerceService/2005-10-05">
<OperationRequest>
<RequestId>xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx</RequestId>
.......(the rest of the xml is irrelevant)..........

The node my XPath returns is always null for some reason. Can someone help?

© Stack Overflow or respective owner

Related posts about c#

Related posts about Xml