1

I have a web service which returns the following response:

<?xml version="1.0" encoding="utf-8"?>
<string xmlns="http://tempuri.org/">ba7665f2-4548-4f85-9b23-d8979f000722</string>

Using jQuery I thought I could do something like $(response).find('string').text(); to get the string value from my xml.

However this doesn't work and in fact $(response).find('string').length equals 0.

How can I use javascript to get the string value from this xml?

1
  • How are you calling "response"? Commented Jul 5, 2011 at 16:51

2 Answers 2

1

Assuming you're getting the response text correctly, it's possible you're forgetting to call parseXML before you call find. Take a look at the sample script on this page

http://api.jquery.com/jQuery.parseXML/

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

Comments

1

I'm assuming you're using $.ajax(), $.post(), or $.get()? If so, try this:

var myString = response.d;

example:

...
$.ajax({
    type: "POST",
    url: "myURL",
    data: "{}",
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function (response) {

        var myString = response.d;

    }
    ...

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.