By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,946 Members | 744 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,946 IT Pros & Developers. It's quick & easy.

want to add a new node in xml file using javascript

P: 4
I have an image on page and there are some points are placed and one text area is assigned to them.I want to give the name to that points in text area and want to save that in XML file.
and when we open the browser that name should should be there along with the point.

I have done it almost only I cannot save that names in xml...
May 22 '15 #1
Share this Question
Share on Google+
6 Replies


Dormilich
Expert Mod 5K+
P: 8,639
I have done it almost
please show us that code.
May 22 '15 #2

P: 4
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <script src="loadxmldoc.js"> 
  5. </script>
  6. </head>
  7. <body>
  8.  
  9. <script>
  10. xmlDoc=loadXMLDoc("one.xml");
  11.  
  12. newNode=xmlDoc.createElement("book");
  13.  
  14. x=xmlDoc.documentElement;
  15. y=xmlDoc.getElementsByTagName("book");
  16.  
  17. document.write("Book elements before: " + y.length);
  18. document.write("<br>");
  19. x.insertBefore(newNode,y[3]);
  20.  
  21. y=xmlDoc.getElementsByTagName("book");
  22. document.write("Book elements after: " + y.length);
  23. </script></body></html>
May 22 '15 #3

P: 4
Its code for adding node but the error occured in .js file
May 22 '15 #4

Dormilich
Expert Mod 5K+
P: 8,639
what’s the error message?
May 22 '15 #5

P: 4
undefined loadXMLDoc()
May 22 '15 #6

Dormilich
Expert Mod 5K+
P: 8,639
then you should have a look into loadxmldoc.js how you load the file.
May 22 '15 #7

Post your reply

Sign in to post your reply or Sign up for a free account.