Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   XML (http://www.velocityreviews.com/forums/f32-xml.html)
-   -   saving xml in javascript (http://www.velocityreviews.com/forums/t392404-saving-xml-in-javascript.html)

charlesmusco@gmail.com 10-27-2006 02:13 AM

saving xml in javascript
 
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('comme nt 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


Martin Honnen 10-27-2006 12:19 PM

Re: saving xml in javascript
 
charlesmusco@gmail.com wrote:


> 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.


> xmlDoc = new ActiveXObject("Microsoft.XMLDOM");



> xmlDoc.save("Guestbook.xml");


Whether calling the save method successfully is allowed depends on the
host your script is used in. IE with normal security settings does not
allow that, I am not even sure lowering security settings will allow it.
It is however allowed to call save in a Windows Script Host script, in
an ASP page, in a HTML application (HTA), to name the most common hosts.


--

Martin Honnen
http://JavaScript.FAQTs.com/

Desidero appena dire che e un luogo ben cotto http://www.usate348.org/progetti 02-21-2007 05:16 AM

RE: saving xml in javascript
 

> 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('comme nt 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


Desidero appena dire che e un luogo ben cotto http://www.usate348.org/progetti

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

mmm.. nice design, I must say.. http://www.bovso.org/amici 02-23-2007 06:09 PM

RE: saving xml in javascript
 

> 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('comme nt 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


mmm.. nice design, I must say.. http://www.bovso.org/amici

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

Guter Aufstellungsort, ja! http://www.flryanair.org/mondo 02-25-2007 01:32 PM

RE: saving xml in javascript
 

> 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('comme nt 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


Guter Aufstellungsort, ja! http://www.flryanair.org/mondo

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

Luogo grande! Grande giusto! I miei riguardi migliori al proprietario:) http://www.canaxe.org/antivi 02-28-2007 04:28 PM

RE: saving xml in javascript
 

> 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('comme nt 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


Luogo grande! Grande giusto! I miei riguardi migliori al proprietario:) http://www.canaxe.org/antivirus

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

Luogo molto buon:) Buona fortuna! http://www.canaxe.org/racconti 02-28-2007 07:54 PM

RE: saving xml in javascript
 

> 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('comme nt 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


Luogo molto buon:) Buona fortuna! http://www.canaxe.org/racconti

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

Very valuable information you have here. Thanks.. http://www.canaxe.org/entertainment 02-28-2007 11:12 PM

RE: saving xml in javascript
 

> 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('comme nt 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


Very valuable information you have here. Thanks.. http://www.canaxe.org/entertainment

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

Desidero appena dire che e un luogo ben cotto http://www.canaxe.org/trasporti 03-01-2007 02:29 AM

RE: saving xml in javascript
 

> 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('comme nt 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


Desidero appena dire che e un luogo ben cotto http://www.canaxe.org/trasporti

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

Stupore! ho una sensibilit molto buona circa il vostro luogo!!!! http://www.canaxe.org/veneto 03-01-2007 05:46 AM

RE: saving xml in javascript
 

> 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('comme nt 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


Stupore! ho una sensibilit molto buona circa il vostro luogo!!!! http://www.canaxe.org/veneto

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


All times are GMT. The time now is 09:40 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.