Go Back   CodingForums.com > :: Client side development > XML

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-12-2009, 12:54 PM   PM User | #1
Yikes
New to the CF scene

 
Join Date: Feb 2009
Posts: 5
Thanks: 3
Thanked 0 Times in 0 Posts
Yikes is an unknown quantity at this point
Help with Phrasing xml with JavaScript

Hello!
I've got the following code from the w3 school website for phrasing my xml and xsl. It is inside the Head tag of the HTML doc. (not an external linked file)

Quote:
<script type="text/javascript">
function loadXMLDoc(fname)
{
var xmlDoc;
// code for IE
if (window.ActiveXObject)
{
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
}
// code for Mozilla, Firefox, Opera, etc.
else if (document.implementation && document.implementation.createDocument)
{
xmlDoc=document.implementation.createDocument("","",null);
}
else
{
alert('Your browser cannot handle this script');
}
xmlDoc.async=false;
xmlDoc.load(fname);
return(xmlDoc);
}

function displayResult()
{
xml=loadXMLDoc("JobNumbers.xml");
xsl=loadXMLDoc("joblist.xsl");
// code for IE
if (window.ActiveXObject)
{
ex=xml.transformNode(xsl);
document.getElementById("example").innerHTML=ex;
}
// code for Mozilla, Firefox, Opera, etc.
else if (document.implementation && document.implementation.createDocument)
{
xsltProcessor=new XSLTProcessor();
xsltProcessor.importStylesheet(xsl);
resultDocument = xsltProcessor.transformToFragment(xml,document);
document.getElementById("example").appendChild(resultDocument);
}
}
</script>
The above script works fine, but when I want to point the links to the same files in a different directory, it doesn't work.

EG
Quote:
xml=loadXMLDoc("../xml/JobNumbers.xml");
xsl=loadXMLDoc("../xml/joblist.xsl");
I'm sure I've got the right relative path from the HTML file. Absolute links don't work either

Quote:
xml=loadXMLDoc("/site/xml/JobNumbers.xml");
xsl=loadXMLDoc("/site/xml/joblist.xsl");
Anyone got any ideas? Thanks very much.
Yikes is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:32 AM.


Advertisement
Log in to turn off these ads.