Shoutbox

How to write to xml file? - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: How to write to xml file? (/showthread.php?tid=64240)

How to write to xml file? by y2kbug on 07-30-2006 at 04:33 PM

I would like to write some text to an xml file. First, I would like to know how to open a file to write? And then, how to "write" to the file, and at last, how to save it? I know how to use FileSystemObject in Visual Basic 6, but it seems that it doesn't work in the same syntax in this system.

Another question is that, when calling MsgPlus.DisplayToast, how to output a line break? I cannot use HTML tag <br> and also what I use in VB6 - chr(13).

Thanks!!


RE: How to write to xml file? by Squelettor on 07-30-2006 at 09:05 PM

quote:
Originally posted by y2kbug
Another question is that, when calling MsgPlus.DisplayToast, how to output a line break? I cannot use HTML tag <br> and also what I use in VB6 - chr(13).

Try with '\n'

RE: How to write to xml file? by y2kbug on 07-31-2006 at 07:00 AM

quote:
Originally posted by Squelettor
quote:
Originally posted by y2kbug
Another question is that, when calling MsgPlus.DisplayToast, how to output a line break? I cannot use HTML tag <br> and also what I use in VB6 - chr(13).

Try with '\n'


It works!
Thankyou!
RE: How to write to xml file? by CookieRevised on 07-31-2006 at 08:20 AM

But note that there is currently a 'bug' with it....

When the lines preceding the line break are too long, the line break seems to be ignored and you get stuff like:

"This_is_a_very_long_string_which_I_write_to_show_something\nsecond_line"

displays something like:

This_is_a_very_long_string_which_I_wri
te_to_show_somethingsecond_line


Instead of the expected:

This_is_a_very_long_string_which_I_wri
te_to_show_something
second_line


RE: How to write to xml file? by rob_botch on 07-31-2006 at 12:31 PM

To write to xml:

code:
var xml = new ActiveXObject("Microsoft.XMLDOM"); //Create xml object
xml.load(XMLPath); //XMLPath is the path of your XML file

var toAdd = xml.createElement("Element"); //Create an element called "Element"

toAdd.appendChild(xml.createTextNode("Text")); //Add the text "Text" to the element that you just created

xml.getElementsByTagName("Parent")[0].appendChild(toAddMessage); //Add the newly created element to the first instance of "Parent"

xml.save(XMLPath); //Save the XML file to the path specified


I hope that this helps,

Robert
RE: How to write to xml file? by y2kbug on 07-31-2006 at 03:58 PM

quote:
Originally posted by rob_botch
To write to xml:

code:
var xml = new ActiveXObject("Microsoft.XMLDOM"); //Create xml object
xml.load(XMLPath); //XMLPath is the path of your XML file

var toAdd = xml.createElement("Element"); //Create an element called "Element"

toAdd.appendChild(xml.createTextNode("Text")); //Add the text "Text" to the element that you just created

xml.getElementsByTagName("Parent")[0].appendChild(toAddMessage); //Add the newly created element to the first instance of "Parent"

xml.save(XMLPath); //Save the XML file to the path specified


I hope that this helps,

Robert


I wanna say thankyou to you first. I have to find out more about this before I can tell whether it works or not.