PDA

View Full Version : xml for dynamic content on XHTML w/ Javascript



Cuervo
07 May 2009, 12:22 AM
I am not sure if this is the right place...
Anyway, I am somewhat new with Javascript.
I want to have one xhtml template that I use to load xml content into.
I have the template and xml content but I can't figure out how to load the xml into the xhtml through DOM.

I haven't even successfully put anything on my website through DOM.

Here is the two things I have tried (that seemed the best):
content=document.implementation.createDocument("","",null);
content.async="false";
content.load("home.xml");

page=document.implementation.createDocument("","",null);
page.async="false";
page.load("site.xhtml");

var title;
title = content.getElementsByTagName("title")[0].childnodes[0].nodeValue ;
page.getElementsByTagName("title")[0].childnodes[0].nodevalue = title;

and (trying to load any text at all)
var newtext = document.createTextNode(" Some text added dynamically. ");
var para = document.getElementById("p1");
para.appendChild(newtext);

PS I am using Safari Beta 4 and Firefox 3