DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2010
    Posts
    2

    Creating XML nodes via DOM

    Hey, there!
    Guys, Im in a sort of a... tag.
    According to w3schools.com, in order to create nodes in XML, all one has to do is
    HTML Code:
    xmlDoc=loadXMLDoc("archive.xml")//xml reader parser
    var p_root=xmlDoc.getElementsByTagName("root") //XML archive's root
    var new_element=xmlDoc.createElement("new_element")
    var new_text=new_element.createTextNode("Text")
    new_element.appendChild(new_text)
    
    p_root.appendChild(new_element)
    ... And that should do it. But, and a very big But indeed, it doesn't create at all. No new elements in the XML document, no appending whatsoever.
    AND, no help from the Mozilla's Error Console (ctrl+alt+j) either.
    Any clues?

  2. #2
    Join Date
    May 2009
    Location
    United Kingdom
    Posts
    49
    Generally you would need to save the document in some form to see the changes, unless, for example, it is being run from javascript and modifying the current HTML page.
    Hope that helps...

  3. #3
    Join Date
    Jul 2010
    Posts
    2
    Yes, wel... The data *are* being processed via HTML Form, with no server-side client (sucha as Asp), wihch, I have to say, I'm inclined to change.
    When you say "save in a document", you mean, by server applications, right?

  4. #4
    Join Date
    May 2009
    Location
    United Kingdom
    Posts
    49
    It was a general comment for XML, but in your case yes.

    Basically, unless there is something which is representing a live version of the DOM you will not see any changes unless the DOM you are modifying is saved back to either the file that you loaded or a new file. When the DOM is modified using appendChild() etc. it is only amending the in memory version of the DOM.

Similar Threads

  1. Save XML DOM object to XML file
    By JCGrafted in forum XML
    Replies: 0
    Last Post: 03-09-2010, 11:20 AM
  2. creating a xml file using VB and DOM
    By harish13 in forum VB Classic
    Replies: 2
    Last Post: 07-25-2006, 11:43 PM
  3. Creating XML document using DOM
    By Gee in forum XML
    Replies: 2
    Last Post: 06-14-2001, 12:19 PM
  4. XML DOM: selecting nodes and deleting them
    By Mark Dempsey in forum XML
    Replies: 0
    Last Post: 07-26-2000, 04:28 PM
  5. Replies: 1
    Last Post: 03-22-2000, 09:09 AM

Bookmarks

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
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links