PHJCJO PHJCJO - 1 year ago 111
jQuery Question

Access nodes from an xml with in an iframe

I loaded an XML file to an iframe with the intention of accessing the xml nodes from java-script, using pure js or jquery with supporting cross browser.

<!DOCTYPE html>
<iframe id='contentHolder' src='../xml/BookList.xml'></iframe>

Answer Source

with jquery:

<iframe src="../xml/BookList.xml" id="contentHolder"></iframe>

$( "#contentHolder" ).load(function () {
   console.log("iframe loaded")
   console.log($( "#contentHolder" ).contents().find("body").text())

see the article on their website: