Altova Mailing List Archives


RE: saving xml in javascript

From: "Interesting comments.. :D http://www.titgcino80.org/juventus"<juventus8537@-----.--->
To: NULL
Date: 3/9/2007 12:55:00 PM


> Hi all. I have the following problem. I have an xml file, while I will
> list below and I am trying to add nodes to the xml document based on
> user input to a form.
> 
> The XML doc is ...
> 
> <?xml version="1.0"?>
> 
> <board>
>     <message>
>         <author> Author One </author>
>         <comment> This is the first test comment </comment>
>     </message>
>     <message>
>         <author> Author Two </author>
>         <comment> This is the second test comment </comment>
>     </message>
>     <message>
>         <author> Author Three </author>
>         <comment> This is the third test comment </comment>
>     </message>
> </board>
> 
> 
> The code I have to insert a new node is ....
> 
> <script type="text/javascript">
>        var xmlDoc;
>        var xmlObj;
>        var author;
>        var comment;
>        var message;
>        function loadXMLDoc() {
> 
>            xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
>            xmlDoc.async="false";
>            xmlDoc.load("Guestbook.xml");
>            xmlObj=xmlDoc.documentElement;
>            processInput();
>          }
> 
>          function processInput() {
>         var new_message=xmlDoc.createElement('message');
>         var new_author=xmlDoc.createElement('author');
>         var new_comment=xmlDoc.createElement('comment');
>         var new_author_text=new_author.createTextNode('author test
> works');
>         var new_comment_text=new_comment.createTextNode('comment test
> works');
>         new_message.appendChild(new_author);
>         new_message.appendChild(new_comment);
>         xmlObj.appendChild(new_message);
>         xmlDoc.save("Guestbook.xml");
>        }
> 
> </script>
> 
> 
> Currently when I execute this is makes no change whatsoever to the xml
> file. What I expected was to open the xml doc manually and see 4 child
> nodes of the root instead of 3 as shown above in the xml listing. Any
> thoughts or ideas on what I'm doing wrong?
> 
> Also of note is the above code is in the head section of a JSP file.
> Just using JSP instead of HTML file but no jsp code is actually in the
> file, just html.
> 
> Thanks,
> Charles

Interesting comments.. :D http://www.titgcino80.org/juventus

BizTalk Utilities - Frustration free BizTalk Adapters
http://www.topxml.com/biztalkutilities

Disclaimer

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.