0

I have the following XML:

<item p4:stage="Ways and Means resolution" xmlns:p4="urn:services.parliament.uk-bills.ext"><guid isPermaLink="true">http://services.parliament.uk/bills/2013-14/antisocialbehaviourcrimeandpolicingbill.html</guid><link>http://services.parliament.uk/bills/2013-14/antisocialbehaviourcrimeandpolicingbill.html</link><category>Commons</category><category>Government Bill</category><title>Anti-social Behaviour, Crime and Policing</title><description>To make provision about anti-social behaviour, crime and disorder, including provision about recovery of possession of dwelling houses; to make provision amending the Dangerous Dogs Act 1991, Schedules 7 and 8 to the Terrorism Act 2000 and the Extradition Act 2003; to make provision about firearms and about forced marriage; to make provision about the police, the IndependentPolice Complaints Commission and the Serious Fraud Office; to make provision about criminal justice and court fees; and for connected purposes.</description><a10:updated>2013-06-05T17:42:59+01:00</a10:updated></item>

I can parse all thats within <item></item> using this:

$(xml).find('item').each(function() {
    var stage = $(this).find('title').text();
    console.log(stage);
});

But I am looking at whats inside :

<item....>  for example, 

I need to pull whats inside:

 <p4:stage></p4:stage>

How do I pull this out ?

Thank you in advance

1 Answer 1

3

There is no <p4:stage></p4:stage> in that invalid XML, p4:stage is an attribute on the item element

$(xml).find('item').each(function() {
    var p4 = $(this).attr('p4:stage');
    console.log(p4);
});

FIDDLE

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.