/    Sign up×
Community /Pin to ProfileBookmark

[COLOR=Navy]Ok I’ve got a prob here
I have this code to parse an XML doc in a webpage: –[COLOR=DarkRed]

[CODE]
<html>
<head>
<script>
function importXML()
{
if (document.implementation && document.implementation.createDocument)
{
xmlDoc = document.implementation.createDocument(“”, “”, null);
xmlDoc.onload = createTable;
}
else if (window.ActiveXObject)
{
xmlDoc = new ActiveXObject(“Microsoft.XMLDOM”);
xmlDoc.onreadystatechange = function () {
if (xmlDoc.readyState == 4) createTable()
};
}
else
{
alert(‘Your browser can’t handle this script’);
return;
}
[B]xmlDoc.load(“del.xml”);[/B]
}

function createTable()

{
var x = xmlDoc.getElementsByTagName(’emperor’);
var newEl = document.createElement(‘TABLE’);
newEl.setAttribute(‘cellPadding’,5);
var tmp = document.createElement(‘TBODY’);
newEl.appendChild(tmp);
var row = document.createElement(‘TR’);
for (j=0;j<x[0].childNodes.length;j++)
{
if (x[0].childNodes[j].nodeType != 1) continue;
var container = document.createElement(‘TH’);
var theData = document.createTextNode(x[0].childNodes[j].nodeName);
container.appendChild(theData);
row.appendChild(container);
}
tmp.appendChild(row);
for (i=0;i<x.length;i++)
{
var row = document.createElement(‘TR’);
for (j=0;j<x[i].childNodes.length;j++)
{
if (x[i].childNodes[j].nodeType != 1) continue;
var container = document.createElement(‘TD’);
var theData = document.createTextNode(x[i].childNodes[j].firstChild.nodeValue);
container.appendChild(theData);
row.appendChild(container);
}
tmp.appendChild(row);
}
document.getElementById(‘writeroot’).appendChild(newEl);
}
</script>

<body onload=”importXML()”>

<div id=”writeroot”>
</div>

</body>
</html>[/CODE]

[/COLOR]The problem is that i want “del.xml” to be a php file on my server if I set del.xml to another file sxtension e.g. txt or php it wont get the file in FireFox help PPPPPLLLEEEEAAAAAASSSSSSSEEEE!!!!!!
[/COLOR]

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@nshiellauthorOct 26.2005 — does any1 have any ideas?
Copy linkTweet thisAlerts:
@A1ien51Oct 26.2005 — Follow the link in my blog that I posted today and grab the zip file at the bottom of my article. .

http://radio.javaranch.com/pascarello/2005/10/26/1130348276996.html

Add that external js file (net.js) to your page. The file is a version of the code from my book Ajax In Action. This Ajax file allows you to make a XMLHttpRequest with one easy line like the following:

<i>
</i>function makeRequest(){
var loader1 = new net.ContentLoader("YourPHPfile.php",finishRequest,null,"GET");
}


and to get the request
<i>
</i>function finishRequest(){
var strDocument = this.req.responseText;
var xmlDocument = this.req.responseXML;
}


It should eliminate the trouble you are having.

Eric
×

Success!

Help @nshiell spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...