JQuery innerXml element

I have the following simple xml:

<xmldoc> <first><node></node></first> </xmldoc> 

I want to select the given node and get the internal XML text.

 $(xml).find('xmldoc').**OuterXMLFunctionThatNotExists**()="<first><node></node></first>" 

Thanks in advance.

+4
source share
3 answers

var text = $(xml).html();

He works in chrome

EDIT : let xml be a text file, not an XML file, because jquery will treat it as a new html element. (e.g. document.createElement ())

var text = $("<xmldoc> <first><node></node></first> </xmldoc>").html();

Or am I assuming you get it from an ajax call? Then don't set dataType to xml (jQuery) or use XHR.responseText

you get only text, and text can be easily parsed using jQuery.

+1
source

try it

var text = $(xml).find('xmldoc').text();

-1
source

Try the following:

  $(xml).find('xmldoc').parent().text(); 
-1
source

All Articles