Solved

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

Posted on 2011-09-10
8
1,063 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 75

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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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
 
LVL 75

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 75

Expert Comment

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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

749 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