I think that you need to do it with Ajax. When making a server request in Ajax, the data returned can be in either plain text/html, or an XML document instead. The later is technically just a text file as well, but with some special instructions, Ajax can retrieve that well formed XML text file and return it back to you as a XML object. This enables the XML data to be easily parsed using standard DOM methods.
Here's a simple XML document. It is showed in RSS format I'll be using for illustration (lets name it "results.xml"):
<rss version="0.91">
<channel>
<title>domain.com</title>
<link>http://www.domain.com</link>
<description>free scripts showing XML document</description>
<language>en</language>
<item>
<title>Document Text Resizer</title>
<link>http://www.domain.com/script/script2/doctextresizer.shtml</link>
<description>This script adds the ability for your users to toggle your webpage's font size, with persistent cookies then used to remember the setting</description>
</item>
<item>
<title>JavaScript Reference- Keyboard/ Mouse Buttons Events</title>
<link>http://www.domain.com/jsref/eventkeyboardmouse.shtml</link>
<description>The latest update to our JS Reference takes a hard look at keyboard and mouse button events in JavaScript, including the unicode value of each key.</description>
</item>
<item>
<title>Dynamically loading an external JavaScript or CSS file</title>
<link>http://www.domain.com/javatutors/loadjavascriptcss.shtml</link>
<description>External JavaScript or CSS files do not always have to be synchronously loaded as part of the page, but dynamically as well. In this tutorial, see how.</description>
</item>
</channel>
</rss>
The below shows retrieving this XML document and outputing the headlines ("title" elements) of each entry:
<script type="text/javascript">
function ajaxRequest(){
var activexmodes=["Msxml2.XMLHTTP", "Microsoft.XMLHTTP"]
if (window.ActiveXObject){
for (var i=0; i<activexmodes.length;> try{
return new ActiveXObject(activexmodes[i])
}
catch(e){
}
}
}
else if (window.XMLHttpRequest)
return new XMLHttpRequest()
else
return false
}
var mygetrequest=new ajaxRequest()
if (mygetrequest.overrideMimeType)
mygetrequest.overrideMimeType('text/xml')
mygetrequest.onreadystatechange=function(){
if (mygetrequest.readyState==4){
if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
var xmldata=mygetrequest.responseXML
var rssentries=xmldata.getElementsByTagName("item")
var output='<ul>'
for (var i=0; i<rssentries.length;> output+='<li>'
output+='<a href="'+rssentries[i].getElementsByTagName('link')[0].firstChild.nodeValue+'">'
output+=rssentries[i].getElementsByTagName('title')[0].firstChild.nodeValue+'</a>'
output+='</li>'
}
output+='</ul>'
document.getElementById("result").innerHTML=output
}
else{
alert("An error has occured making the request")
}
}
}
mygetrequest.open("GET", "results.xml", true)
mygetrequest.send(null)
</script>
I hope that it will be useful