Bran-Damage
asked on
XML parsing error 'x://shipto/name' has an invalid qualified name.
I am trying to parse an XML and I am stuck. The XML has a namespace which is making this more difficult.
I have attached the code, it is blowing up on the line:
objShipTo.strSTContact = root.SelectSingleNode("x:/ /shipto/na me", nsmgr).InnerText.ToString( );
I have attached the XML as well.
Thanks for your help.
I have attached the code, it is blowing up on the line:
objShipTo.strSTContact = root.SelectSingleNode("x:/
I have attached the XML as well.
Thanks for your help.
private bool FillShipTo(XmlDocument xmlDoc)
{
try
{
objShipTo = new InterfaceShipTo();
XmlElement root = xmlDoc.DocumentElement;
XmlNamespaceManager nsmgr = new XmlNamespaceManager(xmlDoc.NameTable);
nsmgr.AddNamespace("x", root.NamespaceURI); // x is our temp alias
objShipTo.strSTContact = root.SelectSingleNode("x://shipto/name", nsmgr).InnerText.ToString();
return true;
}
catch (Exception ex)
{
return false;
}
}
Response.xml
"x://shipto/name" should be "x:/shipto/name". If that gives you an, you can try it the other way, "x://shipto//name", but normally you specify a website the first way I wrote, but drives in C# may be different and you have to use // to actually display a /.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I guess I was way off then!
ASKER
Thanks for the help, i tried the x: in front of each node, and I got this error
'x://shipto/x:name' has an invalid qualified name.
'x://shipto/x:name' has an invalid qualified name.
That's not the XPath I specified...
ASKER
oh... haha, wupps. Got the x: messed up, trying it now.
ASKER
Perfect, thanks.
NP. Glad to help = )