2

I am trying to get the content of an XML Element into a variable:

<ContactPresence>
<ContactUri>test.com</ContactUri>
<PresenceState>offline</PresenceState>
</ContactPresence>

How can I get "PresenceState" into a variable?

1 Answer 1

1

With jQuery, you can use parseXML

  var xml = "<ContactPresence><ContactUri>test.com</ContactUri<PresenceState>offline</PresenceState></ContactPresence>",
  xmlDoc = $.parseXML( xml ),
  $xml = $( xmlDoc ),
  $node = $xml.find( "PresenceState" );

  var presenceState = $node.text(); // Should contain offline
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.