I am having trouble getting the xml object out of an iFrame. I'm using an iFrame to upload a document, which does xmlhttprequest doesn't seem to support. I'm trying the following script, which works great in FireFox but not in IE.
I have tried creating an XML document but could not figure out how load the contents using the a script I found at
http://www.quirksmode.org/dom/importxml.html but I could not figure out how to load the contents of my iFrame into the xmlDoc created using the script there.
What can I do to get IE to recognize that the source of the iFrame is an XML document?
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript" src="/js/ajaxobject.js"></script>
<script type="text/javascript">
function showContent(i) {
var theXML = i.contentWindow.document;
var errors = new Array()
var count = 0;
xml_errors = theXML.getElementsByTagName("error");
//check if any errros were returned
if(xml_errors.length>0) {
//loop through those errors
for(i=0;i<xml_errors.length;i++) {
//and if there is any data to display
if(xml_errors[i].firstChild) {
//assign it to the errors array.
errors[i] = xml_errors[i].firstChild.nodeValue;
count++;
}
}
}
if(errors.length) {
alert(errors[0]);
}
else {
alert("You're golden");
}
}
</script>
</head>
<body>
<p>I Frame</p>
<iframe id="iFrame" width="400" height="500" src="xml.php" onload="showContent(this)"></iframe>
</body>
</html>
And the XML src file is
Code:
<?PHP
header("content-type:text/xml");
echo '<?xml version="1.0" encoding="utf-8"?>' ;
?>
<stuff>
<name>Robbert</name>
<name>Kelly</name>
<name>Jonathon</name>
<name>Carl</name>
<error>Uh Oh</error>
</stuff>
I changed