0

i am using 3rd party api and this is what is its returning me:

<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>
\u000a
<errorNotification>
\u000a\u0009
<message>invalid company code<\/message>
\u000a
<\/errorNotification>

my question is: how can just extract the <message> from the above string/xml?

1 Answer 1

3
var xml = '<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\u000a<errorNotification>\u000a\u0009<message>invalidcompanycode<\/message>\u000a<\/errorNotification>',
xmlDoc = $.parseXML( xml ),
$xml = $( xmlDoc ),
message= $xml.find( 'message' ).text();


alert(message);

Demo: http://jsfiddle.net/ycLms/

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

2 Comments

i am using jquery 1.4 and here is what the error i am getting Microsoft JScript runtime error: Object doesn't support this property or method
@Abu Hamzah jQuery.parseXML() added in version 1.5 of jQuery. Check if you can use this version with your current code without have any error.

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.