PDA

View Full Version : loading xml file


logain
04-21-2005, 06:12 PM
I was following the XML tutorial on the site here. Code is as follows:

tuteInfo_xml = new XML();
tuteInfo_xml.ignoreWhite = true;
tuteInfo_xml.onLoad = function(success) {
if (success) {
trace('Author.xml loaded. Contents are: '+this.toString());
}
};
tuteInfo_xml.load('author.xml');

However the trace of this.toString() is giving me an udefined, not the contents of the file. I am loading the file because I am getting the output from trace, but the last part of it seems broken.

mmm..pi..3.14..
04-21-2005, 06:17 PM
tuteInfo_xml = new XML();
tuteInfo_xml.ignoreWhite = true;
tuteInfo_xml.onLoad = function(success) {
if (success) {
trace('Author.xml loaded. Contents are: '+this);
}
};
tuteInfo_xml.load('author.xml');

and if that doesn't work...

tuteInfo_xml = new XML();
tuteInfo_xml.ignoreWhite = true;
tuteInfo_xml.onLoad = function(success) {
if (success) {
trace('Author.xml loaded. Contents are: '+unescape(this));
}
};
tuteInfo_xml.load('author.xml');

Eric :D

logain
04-21-2005, 06:22 PM
It gives me 'author.xml loaded. Contents are: [type Object]' so I assume everything is working then?

mmm..pi..3.14..
04-21-2005, 06:33 PM
well actually it should trace the contents of the xml file, but it's a start. Post your XML file...maybe theres something different in there :)

mmm..pi..3.14..
04-21-2005, 06:34 PM
wait forgot to ask...where is your actionscript located?? Is it in a button or in a frame?

logain
04-21-2005, 06:39 PM
It is in a frame and my xml is

<xml>
<pic>
<name>trial</name>
<type>.jpg</type>
</pic>
</xml>

My end goal is to make a xml database of artwork that will be load the artwork externally.

logain
04-21-2005, 06:40 PM
Hmm... It doesnt appear to like my tabs.

mmm..pi..3.14..
04-21-2005, 06:59 PM
you need to use a tag to do indenting, and tabs won't work, tabs just jump to the next object on the page. I just press space 5 times for indenting :)

this code worked on my side:

tuteInfo_xml = new XML();
tuteInfo_xml.ignoreWhite = true;
tuteInfo_xml.onLoad = function(success) {
if (success) {
trace('Author.xml loaded. Contents are: '+tuteInfo_xml);
}
};
tuteInfo_xml.load('author.xml');

Eric :)

logain
04-26-2005, 05:15 PM
mkay. will try on my home computer instead of the crappy school computers. heh.