sturz001
06-20-2008, 12:06 PM
Hello!
I am hoping to create a form that sets new elements in an XML document, but knowing the best way to learn is to do it yourself, I would like a try first. BUT! So that I am not doomed to failure I will keep updating this tread on my progress and asking for advice. My first gripe is a bit of XML DOM:
xmlDoc=loadXMLDoc("gameslinker.xml");
setgametag=xmlDoc.createElement("game");
setgnametag=xmlDoc.createElement("gname");
gnamevalue=xmlDoc.createTextNode(gnamefield);
setitup1=setgametag.appendChild(setgnametag);
setitup2=setitup1.appendChild(gnamevalue);
x=xmlDoc.getElementsByTagName("comped")[0];
x.appendChild(setitup2);
Here, you must know that gnamefield is a variable that I will use HTML DOM to get the contents of a form field that will contain the text node of <gname>
I'm hoping the code above will generate this XML code:
<comped>
<game>
<gname>This will be the same as gnamefield</gname>
</game>
.....more game tags that will be here already....
</comped>
Please correct me if I'm wrong!
Thanks!
Zac
I am hoping to create a form that sets new elements in an XML document, but knowing the best way to learn is to do it yourself, I would like a try first. BUT! So that I am not doomed to failure I will keep updating this tread on my progress and asking for advice. My first gripe is a bit of XML DOM:
xmlDoc=loadXMLDoc("gameslinker.xml");
setgametag=xmlDoc.createElement("game");
setgnametag=xmlDoc.createElement("gname");
gnamevalue=xmlDoc.createTextNode(gnamefield);
setitup1=setgametag.appendChild(setgnametag);
setitup2=setitup1.appendChild(gnamevalue);
x=xmlDoc.getElementsByTagName("comped")[0];
x.appendChild(setitup2);
Here, you must know that gnamefield is a variable that I will use HTML DOM to get the contents of a form field that will contain the text node of <gname>
I'm hoping the code above will generate this XML code:
<comped>
<game>
<gname>This will be the same as gnamefield</gname>
</game>
.....more game tags that will be here already....
</comped>
Please correct me if I'm wrong!
Thanks!
Zac