We need you!

We're working hard on the next version of Developer Fusion. Let us know what you think we should be up to!

Members

Technology Zones

Articles

Hosted By

MaximumASP

Info

XPATH complaining...

Last post 01-10-2008 4:05 PM by joe90. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 01-04-2008 4:27 PM

    • kruelintent
    • Top 200 Contributor
    • Joined on 01-02-2003
    • United Kingdom
    • Addicted Member
    • Points 705

    XPATH complaining...

    I have a VB.net application using an API and getting back large amounts of XML.

    In my VB I use code like this to get a list of nodes and then a FOR EACH loop to go through them...

    Dim XMLNodeList as XML.XMLNodeList = XMLReply.SelectNodes("//Book")

    This would get me a list of the <Book> nodes for me to play with.

    This works fine.

    The problem I have is that the XML returned from this one API has nodes with names like <hello:world> or <big:problem>

    The words don't matter. The point is that they have colons : in them... When I now run the above code to get my list it throws a big error like this

    Run-time exception thrown : System.Xml.XPath.XPathException - Namespace Manager or XsltContext needed. This query has a prefix, variable, or user-defined function.

    So I am guessing I need to escape my XPATH somehow or find another way....

    Any ideas anybody. I have been scratching my head on this for way too long already

    Thanks in advance

    Tom.

    • Post Points: 10
  • 01-10-2008 4:05 PM In reply to

    • joe90
    • Top 50 Contributor
    • Joined on 06-15-2005
    • United Kingdom
    • Guru
    • Points 2,925

    Re: XPATH complaining...

    Been awhile since I played with xml, but can't you simply use a global replace on the xml returned (say "_" for ":"), before you then start selecting nodes?

    Joe 

    • Post Points: 5
Page 1 of 1 (2 items)