I have this content from one input value:
var xml_url = $("input").val();
alert(xml_url);
Output:
<trans>
<result>
<item1>1</item1>
<item2>content</item2>
<item3>NA</item3>
<item4>0</item1>
</result>
</trans>
The structure is as a XML file. I want to get this data.
I have this code:
<script language="javascript">
$(document).ready(function(){
var xml_url = $("input").val();
$(xml_url).find("result").each(function()
{
alert($(this).find("item3').").text());
});
});
</script>
It works fine in firefox, but not in IE7/8.
Any suggestions? Thanks a lot.
Never rely on jQuery for parsing XML.
See
Use a proper parser to do the job, and then use jQuery to find the desired nodes. The example you gave works on Firefox, but not on Chrome, Safari or IE. The function below will construct a XML document from a string.
Use as: