I'm using jQuery's XML parser on some simple content that contains HTML.
Extracting the full HTML text using jQuery's .html()
or standard javascript .innerHTML
works fine in Chrome, but not in Internet Explorer 9. jQuery's .text()
works in both cases, but I need the html tags extracted as well.
How can I make it work with IE9 as well?
You can test it out here: http://jsfiddle.net/199vLsgz/
XML:
<script id="xml_data" type="text/xml">
<model_data name="The model ">
<person_responsible></person_responsible>
<objects>
<object name="Available B reports" id="obj1" >
<description>this is a description <br/> oh look, another line!</description>
</object>
</objects>
</model_data>
</script>
Code:
$(function() {
var xml = $("#xml_data").text();
var xmlDoc = $.parseXML(xml);
$xml = $(xmlDoc);
var desc = $xml.find("model_data > objects > object[id='obj1'] > description");
alert(desc.html());
})