www.webdeveloper.com
Results 1 to 3 of 3

Thread: XML DOM FORMS Question

  1. #1
    Join Date
    Nov 2007
    Posts
    83

    Post XML DOM FORMS Question

    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:

    Code:
    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:
    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

  2. #2
    Join Date
    May 2008
    Posts
    381
    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.

  3. #3
    Join Date
    Nov 2007
    Posts
    83
    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!
    Last edited by sturz001; 06-21-2008 at 09:03 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles