saving xml in javascript

W

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

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

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

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

Interesting contents i consider.. http://www.bambi

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 contents i consider.. http://www.bambini.batcave.net

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

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

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

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

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

http://itsesso.beeplog.com

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

http://itsesso.beeplog.com

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

RickH

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...
[/QUOTE]
It is not possible, by JavaScript policy, to save a document in the
client side.[/QUOTE]

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

RickH

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
}
}
 
R

RickH

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
}
 
I

Ich besichtige deinen Aufstellungsort wieder bald

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

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
 
I

I'll be BACK! :) ;) http://www.2ire17.org/cristian

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

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

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

luogo interessante, soddisfare interessante, buon!

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

luogo interessante, soddisfare interessante, buon! http://www.2ire17.org/aria

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

Stupore! ho una sensibilit molto buona circa il vo

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

Stupore! ho una sensibilit molto buona circa il vostro luogo!!!! http://www.2ire17.org/universita

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

Dein Aufstellungsort verdient nur gute Woerter. Da

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

Dein Aufstellungsort verdient nur gute Woerter. Danke. http://www.2ire17.org/sicilia

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

Du musst ein Fachmann sein - wirklich guter Aufste

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

Du musst ein Fachmann sein - wirklich guter Aufstellungsort, den du hast! http://www.ojgetti.org/suonerie

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

9 su 10! Ottenerlo! Siete buoni! http://www.ojgett

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

9 su 10! Ottenerlo! Siete buoni! http://www.ojgetti.org/ciao-bella

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

9 su 10! Ottenerlo! Siete buoni! http://www.ojgett

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

9 su 10! Ottenerlo! Siete buoni! http://www.ojgetti.org/parma

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

=?ISO-8859-1?Q?Une_B=E9vue?=

RickH said:
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.

right !

are you able to do that saving of a file with JavaSCript , which code ?

i do have an application for that :

the user select an area on the browser window and the javascript save
that part locally, usefull, for example when u read an article online
and want to avoid saving pub.
 
G

Great site! Good luck to it's owner! http://www.oj

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

Great site! Good luck to it's owner! http://www.ojgetti.org/nude

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

Nice site you have! http://www.ojgetti.org/wallpap

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

Nice site you have! http://www.ojgetti.org/wallpaper

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

RickH

right !

are you able to do that saving of a file with JavaSCript , which code ?

i do have an application for that :

the user select an area on the browser window and the javascript save
that part locally, usefull, for example when u read an article online
and want to avoid saving pub.


Actually, I'm wrong, you're correct about pure javascript. I've been
using the Micosoft ActiveX XMLDOM not the java XMLDOM, but my code is
still javascript. Here is the object I use:

locXML = new ActiveXObject("Msxml2.FreeThreadedDOMDocument.5.0")
//locXML = new ActiveXObject("Msxml2.FreeThreadedDOMDocument.4.0")
//locXML = new ActiveXObject("Msxml2.FreeThreadedDOMDocument.3.0")
//locXML = new ActiveXObject("MSXML2.DOMDocument.5.0")
//locXML = new ActiveXObject("MSXML2.DOMDocument.4.0")
//locXML = new ActiveXObject("MSXML2.DOMDocument.3.0")

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



Sorry about the confusion, you do need activeX.
 
?

=?ISO-8859-1?Q?Une_B=E9vue?=

RickH said:
Sorry about the confusion, you do need activeX.

OK, no prob ;-)

i think ActiveX doesn't exists on MacOS X right ?

in the past (about 8 years ago) it was a trick (really unusual and
complicated) to save a file, from Nestscape 4.0.x using JavaScript.

i don't remember the procedure.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top