troubleshooting Question

XML parsing error 'x://shipto/name' has an invalid qualified name.

Avatar of Bran-Damage
Bran-DamageFlag for United States of America asked on
8 Comments1 Solution1926 ViewsLast Modified:
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/name", nsmgr).InnerText.ToString();

I have attached the XML as well.

Thanks for your help.

private bool FillShipTo(XmlDocument xmlDoc)
            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;
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 8 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros