Click to See Complete Forum and Search --> : XML DOM FORMS Question


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

rpgfan3233
06-20-2008, 06:20 PM
Assuming gnamefield already has the value of the form field itself rather than being a copy or reference to the form field, your code should work.

sturz001
06-21-2008, 08:51 AM
Thanks rpgfan!

It would be like with HTML DOM
Is XML DOM even the right way to go for a form. I want to be able to add to my xml script with this form and for it to stay there forever (until deleted).
I really want to try avoid all else if possible. I would need LOTS of help if this needed PHP. Tell me to forget it if it needs ASP!