Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > saving xml in javascript

Reply
Thread Tools

saving xml in javascript

 
 
WOW!! I like it! http://www.avwzioni.org/figa
Guest
Posts: n/a
 
      03-02-2007

> 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


WOW!! I like it! http://www.avwzioni.org/figa

BizTalk Utilities - Frustration free BizTalk Adapters
http://www.topxml.com/biztalkutilities
 
Reply With Quote
 
 
 
 
Interesting contents i consider.. http://www.bambini.batcave.net
Guest
Posts: n/a
 
      03-02-2007

> 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


Interesting contents i consider.. http://www.bambini.batcave.net

BizTalk Utilities - Frustration free BizTalk Adapters
http://www.topxml.com/biztalkutilities
 
Reply With Quote
 
 
 
 
http://www.bloggingmylife.com/?u=sessois
Guest
Posts: n/a
 
      03-02-2007

> 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


http://www.bloggingmylife.com/?u=sessois

BizTalk Utilities - Frustration free BizTalk Adapters
http://www.topxml.com/biztalkutilities
 
Reply With Quote
 
http://itsesso.beeplog.com
Guest
Posts: n/a
 
      03-02-2007

> 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


http://itsesso.beeplog.com

BizTalk Utilities - Frustration free BizTalk Adapters
http://www.topxml.com/biztalkutilities
 
Reply With Quote
 
RickH
Guest
Posts: n/a
 
      03-02-2007
On Mar 1, 12:07 am, (E-Mail Removed) (Une Bvue)
wrote:
> > > 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?

>
> It is not possible, by JavaScript policy, to save a document in the
> client side.
>
> You might ask for that using a server side script writen in php for
> example...
> --
> Une Bvue



>>>>>>>>>>>>>>>

> It is not possible, by JavaScript policy, to save a document in the
> client side.
>>>>>>>>>>>>>>>


This is only true if your web page is being served by a web server.
If the web page is a local file on a hard drive that you have rights
to, then the save method works. I use it all the time to write
browser-based applications that dont require a web server to exist on
the users machine. They just click a local html file fill out the
form and save away.


 
Reply With Quote
 
RickH
Guest
Posts: n/a
 
      03-02-2007
On Mar 2, 5:16 pm, "RickH" <(E-Mail Removed)> wrote:
> On Mar 1, 12:07 am, (E-Mail Removed) (Une Bvue)
> wrote:
>
>
>
>
>
> > > > 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?

>
> > It is not possible, by JavaScript policy, to save a document in the
> > client side.

>
> > You might ask for that using a server side script writen in php for
> > example...
> > --
> > Une Bvue

>
> > It is not possible, by JavaScript policy, to save a document in the
> > client side.

>
> This is only true if your web page is being served by a web server.
> If the web page is a local file on a hard drive that you have rights
> to, then the save method works. I use it all the time to write
> browser-based applications that dont require a web server to exist on
> the users machine. They just click a local html file fill out the
> form and save away.- Hide quoted text -
>
> - Show quoted text -



Also, for IE I would also suggest you instantiate the DOM in this
manner: as the class name you are using in the example will give you a
very old version 3 of the DOM, now that the DOM is installed side-by-
side on windows new releases, there is no longer a single clsid for
the DOM. The function below will return the most recent version that
the machine has installed. Also in your type of app make sure the
async property is set to false.



function getXMLDom() {
// Please use the highest version of XML that is currently installed
on your machine
var locXML
try {
locXML = new ActiveXObject("Msxml2.FreeThreadedDOMDocument.6.0" )
}
catch(e) {
try {
locXML = new ActiveXObject("Msxml2.FreeThreadedDOMDocument.5.0" )
}
catch(e) {
try {
locXML = new ActiveXObject("Msxml2.FreeThreadedDOMDocument.4.0" )
}
catch(e) {
try {
locXML = new ActiveXObject("Msxml2.FreeThreadedDOMDocument.3.0" )
}
catch(e) {
try {
locXML = new ActiveXObject("MSXML2.DOMDocument.6.0")
}
catch(e) {
try {
locXML = new ActiveXObject("MSXML2.DOMDocument.5.0")
}
catch(e) {
try {
locXML = new ActiveXObject("MSXML2.DOMDocument.4.0")
}
catch(e) {
try {
locXML = new ActiveXObject("MSXML2.DOMDocument.3.0")
}
catch(e) {
}
}
}
}
}
}
}
}
locXML.async = false
locXML.validateOnParse = true;
locXML.resolveExternals = true;
locXML.setProperty("SelectionLanguage", "XPath");
if (typeof(locXML) == 'undefined') {
alert('Error: you must have the XML DOM installed')
return null
} else {
return locXML
}
}



 
Reply With Quote
 
RickH
Guest
Posts: n/a
 
      03-02-2007
On Mar 2, 5:23 pm, "RickH" <(E-Mail Removed)> wrote:
> On Mar 2, 5:16 pm, "RickH" <(E-Mail Removed)> wrote:
>
>
>
>
>
> > On Mar 1, 12:07 am, (E-Mail Removed) (Une Bvue)
> > wrote:

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

>
> > > It is not possible, by JavaScript policy, to save a document in the
> > > client side.

>
> > > You might ask for that using a server side script writen in php for
> > > example...
> > > --
> > > Une Bvue

>
> > > It is not possible, by JavaScript policy, to save a document in the
> > > client side.

>
> > This is only true if your web page is being served by a web server.
> > If the web page is a local file on a hard drive that you have rights
> > to, then the save method works. I use it all the time to write
> > browser-based applications that dont require a web server to exist on
> > the users machine. They just click a local html file fill out the
> > form and save away.- Hide quoted text -

>
> > - Show quoted text -

>
> Also, for IE I would also suggest you instantiate the DOM in this
> manner: as the class name you are using in the example will give you a
> very old version 3 of the DOM, now that the DOM is installed side-by-
> side on windows new releases, there is no longer a single clsid for
> the DOM. The function below will return the most recent version that
> the machine has installed. Also in your type of app make sure the
> async property is set to false.
>
> function getXMLDom() {
> // Please use the highest version of XML that is currently installed
> on your machine
> var locXML
> try {
> locXML = new ActiveXObject("Msxml2.FreeThreadedDOMDocument.6.0" )
> }
> catch(e) {
> try {
> locXML = new ActiveXObject("Msxml2.FreeThreadedDOMDocument.5.0" )
> }
> catch(e) {
> try {
> locXML = new ActiveXObject("Msxml2.FreeThreadedDOMDocument.4.0" )
> }
> catch(e) {
> try {
> locXML = new ActiveXObject("Msxml2.FreeThreadedDOMDocument.3.0" )
> }
> catch(e) {
> try {
> locXML = new ActiveXObject("MSXML2.DOMDocument.6.0")
> }
> catch(e) {
> try {
> locXML = new ActiveXObject("MSXML2.DOMDocument.5.0")
> }
> catch(e) {
> try {
> locXML = new ActiveXObject("MSXML2.DOMDocument.4.0")
> }
> catch(e) {
> try {
> locXML = new ActiveXObject("MSXML2.DOMDocument.3.0")
> }
> catch(e) {
> }
> }
> }
> }
> }
> }
> }
> }
> locXML.async = false
> locXML.validateOnParse = true;
> locXML.resolveExternals = true;
> locXML.setProperty("SelectionLanguage", "XPath");
> if (typeof(locXML) == 'undefined') {
> alert('Error: you must have the XML DOM installed')
> return null
> } else {
> return locXML
> }
>
>
>
> }- Hide quoted text -
>
> - Show quoted text -- Hide quoted text -
>
> - Show quoted text -


Oops, I'm finding my own bugs, the function previously posted should
end like this:

if (typeof(locXML) == 'undefined') {
alert('Error: you must have the XML DOM installed')
return null
} else {
locXML.async = false
locXML.validateOnParse = true;
locXML.resolveExternals = true;
locXML.setProperty("SelectionLanguage", "XPath");
return locXML
}

 
Reply With Quote
 
Ich besichtige deinen Aufstellungsort wieder bald fur sicheres! http://www.2ire17.org/pokemon-porn
Guest
Posts: n/a
 
      03-03-2007

> 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


Ich besichtige deinen Aufstellungsort wieder bald fur sicheres! http://www.2ire17.org/pokemon-porn

BizTalk Utilities - Frustration free BizTalk Adapters
http://www.topxml.com/biztalkutilities
 
Reply With Quote
 
I'll be BACK! :) ;) http://www.2ire17.org/cristiana
Guest
Posts: n/a
 
      03-03-2007

> 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


I'll be BACK! http://www.2ire17.org/cristiana

BizTalk Utilities - Frustration free BizTalk Adapters
http://www.topxml.com/biztalkutilities
 
Reply With Quote
 
luogo interessante, soddisfare interessante, buon! http://www.2ire17.org/aria
Guest
Posts: n/a
 
      03-03-2007

> 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 interessante, soddisfare interessante, buon! http://www.2ire17.org/aria

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

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Working with XML in JavaScript / XML Javascript'? noff Javascript 0 06-14-2007 12:46 PM
Different results parsing a XML file with XML::Simple (XML::Sax vs. XML::Parser) Erik Wasser Perl Misc 5 03-05-2006 10:09 PM
EXCEL question saving a file saving the the first column as read only Luis Esteban Valencia ASP .Net 0 01-06-2005 07:02 PM
Saving DataTable to session vs saving a Custom object. John Kandell ASP .Net 4 12-10-2004 05:08 AM
Saving Images While Saving ASP Pages ! Lovely Angel For You ASP General 1 10-03-2003 12:03 AM



Advertisments