Reputation: 8295
I have the following:
jQuery.ajax({
type: "GET",
url: "website/Function",
data: '&link=' + link,
contentType: "application/text; charset=utf-8",
dataType: "text",
success: function (data) {
var Link = data.toString();
$('link').val(Link);
}
});
The value from link will be something like:
xml version="1.0" encoding="utf-8"?><string xmlns="http://tempuri.org/">blah /string
How can I manipulate this return value just to extract 'blah'?
'blah' can be dynamic
Thanks to anyone who helps.
Upvotes: 1
Views: 1051
Reputation: 10961
To build off of ulvund's answer: use jQuery.parseXML():
var xmlData = "<?xml version=\"1.0\" encoding=\"utf-8\"?><string xmlns=\"http://tempuri.org/\"> blah </string> ";
$("button").click(function() {
xmlDoc = $.parseXML(xmlData);
$xml = $(xmlDoc);
$('#result').text($xml.find("string").text());
});
This is basically taken right off of jQuery's demo for parseXML()
Upvotes: 2