# Can't open an XML file

**URL:** <https://forum.kirupa.com/t/cant-open-an-xml-file/25872>\
**Category:** programming\
**Created:** [July 17, 2003, 5:46am UTC](https://forum.kirupa.com/t/cant-open-an-xml-file/25872 "2003-07-17T05:46:31Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![javadi82](https://avatars.discourse-cdn.com/v4/letter/j/3be4f8/32.png) [@javadi82](https://forum.kirupa.com/u/javadi82)\
**Post date:** [July 17, 2003, 5:46am UTC](https://forum.kirupa.com/t/cant-open-an-xml-file/25872/1 "2003-07-17T05:46:31Z")

</div>

There is an xml file named:“menu.xml”. It’s path is “C:\menu.xml”.And its code is:  
\<menu\>  
\<mainitem\>  
\<item\>Alphabet\</item\>  
\<subitem\>A\</subitem\>  
\<subitem\>B\</subitem\>  
\</mainitem\>  
\</menu\>

The actionscript written to open the file is :  
myXML= new XML();  
myXML.load(“C:\menu.xml”);  
myXML.onLoad=loaded(success);

function loaded(success){  
if(success) {trace(“Ok”);}  
else {trace("! Ok");}  
}

When the movie is “run” the following error occurs:  
Error opening URL “C:\enu.xml”

My question:The file name is menu.xml but the error statement calls it enu.xml! Why?  
Also why doesn’t the xml file load into the movie?

Please download the movie and help!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 17, 2003, 5:49am UTC](https://forum.kirupa.com/t/cant-open-an-xml-file/25872/2 "2003-07-17T05:49:04Z")

</div>

source code for the xml file is:

\<menu\>  
\<mainitem\>  
\<item\>Alphabet\</item\>  
\<subitem\>A\</subitem\>  
\<subitem\>B\</subitem\>  
\</mainitem\>  
\</menu\>

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 17, 2003, 5:53am UTC](https://forum.kirupa.com/t/cant-open-an-xml-file/25872/3 "2003-07-17T05:53:33Z")

</div>

Well I didn’t set up any test files, but I noticed a few things wrong right off the bat…

1. You are exporting as Flash 5, go to File/Publish Settings and click on the Flash tab and choose Flash 6. Otherwise the dynamic event handlers won’t work.

2. myXML.load(“C:\enu.xml”)… enu.xml? Is that correct?

3. myXML.onLoad = loaded(success)… should be myXML.onLoad = loaded

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 17, 2003, 7:05am UTC](https://forum.kirupa.com/t/cant-open-an-xml-file/25872/4 "2003-07-17T07:05:02Z")

</div>

since i don’t have flash 6 i open the swf file in frhed and change it to flash player 06. then i open the file in flash player 06.(thanks to senocular,for the idea)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 17, 2003, 7:08am UTC](https://forum.kirupa.com/t/cant-open-an-xml-file/25872/5 "2003-07-17T07:08:23Z")

</div>

Oh, well if you are going through all of that, then I have no clue how to help you :-\

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 17, 2003, 7:33am UTC](https://forum.kirupa.com/t/cant-open-an-xml-file/25872/6 "2003-07-17T07:33:47Z")

</div>

to lost in beta:  
could you open the .fla and see what if it works for you.please do try it with an xml file of your own named menu.xml.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 17, 2003, 3:42pm UTC](https://forum.kirupa.com/t/cant-open-an-xml-file/25872/7 "2003-07-17T15:42:26Z")

</div>

Yes, it worked.

I created the menu.xml file in the same directory as the .swf file (didn’t feel like going through all the addressing), then used this code…

[AS]myXML = new XML();  
//added ignoreWhite  
myXML.ignoreWhite = true;  
myXML.load(“menu.xml”);  
myXML.onLoad = loaded;  
function loaded(success) {  
if (success) {  
trace(“Ok”);  
createTextField(“xmltext1”, 1, 100, 100, 200, 200);  
xmltext1.text = “Successfully Loaded!”;  
} else {  
trace("! Ok");  
createTextField(“xmltext2”, 1, 100, 100, 200, 200);  
xmltext2.text = “Unsuccessful!”;  
}  
}[/AS]

And when I tested the movie I got a textbox that said “Successfully Loaded!”

BTW: I added ignoreWhite in there because that is something you should always do when loading in XML. It removes all the excess/useless whitespace from the XML file.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 17, 2003, 7:55pm UTC](https://forum.kirupa.com/t/cant-open-an-xml-file/25872/8 "2003-07-17T19:55:15Z")

</div>

lost, all the above xml actionscript existed in Flash 5, so no pb with that…  
java, when using test movie locally, always test with any files you wanna load in the same folder as your fla/swf, lots of bugs come from there! might just be that you need to escape the \ with \… try…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 17, 2003, 7:57pm UTC](https://forum.kirupa.com/t/cant-open-an-xml-file/25872/9 "2003-07-17T19:57:30Z")

</div>

Eyez: ignoreWhite and createTextField() existed in Flash 5? I thought that was introduced in MX??? :q:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 17, 2003, 8:15pm UTC](https://forum.kirupa.com/t/cant-open-an-xml-file/25872/10 "2003-07-17T20:15:49Z")

</div>

not YOUR actionscript, the one he originally posted! 😉

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 17, 2003, 8:18pm UTC](https://forum.kirupa.com/t/cant-open-an-xml-file/25872/11 "2003-07-17T20:18:35Z")

</div>

Oh… ok, well ignoreWhite is in MY actionscript, but createTextField is in HIS .fla file. (the one in the attachment, not the one in the thread)

😉 😉

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 18, 2003, 12:47pm UTC](https://forum.kirupa.com/t/cant-open-an-xml-file/25872/12 "2003-07-18T12:47:17Z")

</div>

to eyez:I use most of the actionscript commands and functions in flash mx for my flash 5 files. I open frhed and convert the .swf into flash player 06 format.(thanks again senocular).

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 18, 2003, 7:46pm UTC](https://forum.kirupa.com/t/cant-open-an-xml-file/25872/13 "2003-07-18T19:46:42Z")

</div>

@ lost: well i did say

> all the above xml actionscript existed in Flash 5  
> and never looked at the fla… 😉

@javadi: does it work then now?

would be nice when you ask stuff to tell us if it’s solved or not…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 18, 2003, 8:04pm UTC](https://forum.kirupa.com/t/cant-open-an-xml-file/25872/14 "2003-07-18T20:04:33Z")

</div>

Yea, im confuzzled :hangover:

I remember when sen posted the way to get Flash 5 files to act as Flash MX files so you can use the sintax, but I don’t know if it works as well, so I don’t know if this works.

So… does it?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 19, 2003, 7:21am UTC](https://forum.kirupa.com/t/cant-open-an-xml-file/25872/15 "2003-07-19T07:21:56Z")

</div>

YES YES YES.It does work! ‘It’ here implies two things:

1.Senocular’s idea of writing actionscript for flash mx in flash 5 and then changing the .swf format to flashplayer 06 WORKS.

2.I had to only change the  
myXML.onLoad=loaded(success) to  
myXML.onLoad=loaded as lostin beta said and IT WORKED!

Thanks for the help!
