I have a relativly complex xml message I am recieving from a partner company. I need to parse up the xml to use it. I had it working fine, then they changed the message all around and now none of my SelectSingleNode commands work.
Structure of the message. Note the CDATA object with an embedded xml document. Not sure this matters or not. I was able to tweeze out the dataContent object, so it shouldn't make a difference. Here is what I am loading into the XmlDocument:
<ns5:dataContent xmlns:ns2="http://test/common/v1"
xmlns="http://test/schema/common"
xmlns:ns4="http://test/credentialing/stuff/v1"
xmlns:ns3="http://test/schema/ims/common/v1"
xmlns:ns5="http://test/schema/v1">
<createdBy>Micky</createdBy>
<createdAt>2011-03-08T17:00:27.050-05:00</createdAt>
<ns5:Id>39</ns5:Id>
<ns5:Type>4</ns5:Type>
-- lots more data --
</ns5:dataContent>
my code is fairly straight forward
var xmlDoc = new XmlDocument();
xmlDoc.Load(new StringReader(CDATA content));
var xmlNsM = new XmlNamespaceManager(xmlData.NameTable);
xmlNsM.AddNamespace(String.Empty, @"http://test/schema/common\");
xmlNsM.AddNamespace("ns5", @"http://test/schema/v1\");
xmlNsM.AddNamespace("m", @"http://test/message/v1\");
//This works
var order = xmlDoc.ChildNodes[0];
//This returns null
var ID = order.SelectSingleNode("ns5:Id", xmlNsM);
I can see that xmlDoc is being loaded properly. I have tried adding all 6 namespaces to the xmlNsM, but get the same results. None of my SelectSingleNodes works now.
Every post I have found on this subject says to just use the namespace manager, but I already knew that so its not been a very productive afternoon.