-
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?
-
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...
-
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?
-
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
-
By JCGrafted in forum XML
Replies: 0
Last Post: 03-09-2010, 11:20 AM
-
By harish13 in forum VB Classic
Replies: 2
Last Post: 07-25-2006, 11:43 PM
-
Replies: 2
Last Post: 06-14-2001, 12:19 PM
-
By Mark Dempsey in forum XML
Replies: 0
Last Post: 07-26-2000, 04:28 PM
-
Replies: 1
Last Post: 03-22-2000, 09:09 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
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
|
Bookmarks