Ok, so, let’s say I have a string:
var xmlString = '<main><id>5</id><name>test-string</name></main>';
I then want this string to behave like it’s a jQuery obj:
var xmlString = '<main><id>5</id><name>test-string</name></main>',
xmlString = $(xmlString);
Once I do that, I would like to find the value of the ID node:
var xmlString = '<main><id>5</id><name>test-string</name></main>',
xmlString = $(xmlString),
findIdTest = xmlString.find('id').text(),
filterIdTest = xmlString.filter('main').find('id').text();
I try two methods,
xmlString.find('id').text()
and
filterIdTest = xmlString.filter('main').find('id').text();
In FF, Chrome, and IE9, the result is always 5, for both methods.
In IE7 and IE8, I get nothing.. an (empty string)..
Does anyone know why this happening..?
Here’s a fiddle to work with and troubleshoot:
Use
jQuery.parseXMLbefore you create the jQuery object to create a valid XML document.http://api.jquery.com/jQuery.parseXML/