Solved

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

Posted on 2011-09-10
8
989 Views
Last Modified: 2012-05-12
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)
    {
        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;
        }
    }

Open in new window

Response.xml
0
Comment
Question by:Bran-Damage
  • 3
  • 3
  • 2
8 Comments
 
LVL 4

Expert Comment

by:Friman001
ID: 36516629
"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 /.
0
 
LVL 74

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
ID: 36516641
Unless Mono is screwed up, it actually needs to be "//x:shipto/x:name".
0
 
LVL 4

Expert Comment

by:Friman001
ID: 36516680
I guess I was way off then!
0
 

Author Comment

by:Bran-Damage
ID: 36516820
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.

0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 74

Expert Comment

by:käµfm³d 👽
ID: 36516875
That's not the XPath I specified...
0
 

Author Comment

by:Bran-Damage
ID: 36516885
oh... haha, wupps.  Got the x: messed up, trying it now.
0
 

Author Closing Comment

by:Bran-Damage
ID: 36516892
Perfect, thanks.
0
 
LVL 74

Expert Comment

by:käµfm³d 👽
ID: 36516893
NP. Glad to help  = )
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Bit flags and bit flag manipulation is perhaps one of the most underrated strategies in programming, likely because most programmers developing in high-level languages rely too much on the high-level features, and forget about the low-level ones. Th…
In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now