2

I have to parse an xml stream that contains a range of namespaces like this:

<zs:searchRetrieveResponse xmlns="http://www.directoryofchoice.co.uk"
xmlns:zs="http://www.loc.gov/zing/srw/" xmlns:diag="http://www.loc.gov/zing/srw/diagnostic/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.directoryofchoice.co.uk schema/content_node.xsd"
xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/"
xmlns:lom="http://ltsc.ieee.org/xsd/LOM">
<zs:version>1.1</zs:version>
<zs:numberOfRecords>1066</zs:numberOfRecords>
<zs:records>
    <zs:record>
        <zs:recordSchema>info:srw/schema/1/dc-v1.1</zs:recordSchema>
        <zs:recordPacking>xml</zs:recordPacking>
        <zs:recordData>
            <srw_dc:dc xmlns:srw_dc="info:srw/schema/1/dc-schema">
                <dc:title>Mathematics subject leader development materials: Summer

Obviously this is just an indicative chunk of the code. The key point is that I have read about a number of methods (using dc\:title, using "[nodeName=dc:title]" and variations on these, and none of them work at all. I have demonstrated this by taking an xml stream like the one above and changing all the ":" to "-". Then it parses just fine. Is jQuery (I'm using 1.5.1) really not able to handle xml namespaces? That seems an amazing flaw given how common namespaces are nowadays. I don't want to learn another JavaScript toolkit, but is there another one that will handle namespaces?

Ian.

1 Answer 1

1

You have to double-escape the colon ( dc\\:title ) and/or check this article (and the comments) to get some directions: http://www.xml.com/pub/a/2007/10/10/jquery-and-xml.html?page=2

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the response. I had actually double-escaped the colon (one of the escapes got eaten by the message editor!) but it still didn't work. I eventually got things working by going back to an earlier version (1.3.1) of jQuery. Weird that it stopped working in later versions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.