1

I have the following XML that I need to be able to pull specific fields from:

<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">
<id>Cases</id>
<title type="text">CaseList</title>
<updated>2013-04-04T15:32:56Z</updated>
<author>
<name/>
</author>
<link href="CaseList" rel="self" title="CaseList"/>
<entry>
    <id>291</id>
    <title type="text">CaseList('291')</title>
    <updated>2013-04-04T15:32:56Z</updated>
    <category term="S.Cases" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
        <content type="application/xml">
            <m:properties>
                <d:case_id>291</d:case_id>
                <d:case_title>Global Case</d:case_title>
                <d:case_type>Meso</d:case_type>
        </m:properties>
    </content>
</entry>
<entry>
    <id>291</id>
    <title type="text">CaseList('292')</title>
    <updated>2013-04-04T15:38:56Z</updated>
    <category term="S.Cases" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
        <content type="application/xml">
            <m:properties>
                <d:case_id>292</d:case_id>
                <d:case_title>Global Case 2</d:case_title>
                <d:case_type>Meso 2</d:case_type>
        </m:properties>
    </content>
</entry>
</feed>

I've tried almost everything, but I feel that there is a core XML concept I'm missing that would help me extract nodes such as d:case_id. Is there a simple way of pulling out one or more nodes using Javascript? The other namespace questions don't include a namespace within another namespace... here, the values I'm interested in are behind m:properties.

1
  • Further experimenting revealed that using the line x=xmlDoc.getElementsByTagName("entry").length; yields a value of 0 with the code above, a value of 1 if I take away the second "entry" block, and a value of 2 if I take away the "content" fields in both entries... Commented Apr 4, 2013 at 18:15

1 Answer 1

1

I have used this

parentNode.getElementsByTagNameNS("*", "name");

and it worked fine for me in chrome and IE10 browser.

Please follow the below link for details:

jQuery XML parsing with namespaces

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

Comments

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.