?
Solved

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

Posted on 2011-09-10
8
Medium Priority
?
1,143 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 2000 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
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!

 

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

770 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