3 Replies Latest reply on Jan 28, 2010 5:34 PM by hwa-jun yu

    how do I open an XML file?

    ady_lme Level 1


      I'm trying to open an XML file, the xml is in the same directory as the project

      i tried this:


        XMLobject = new(xtra "xmlparser")
        if XMLobject.doneParsing() then put XMLobject.child[1].child[1].name


      It gives me "Script error:Error" at the parseURL line,

      also tried parseURL(_movie.path&"inf.xml") with no luck


      I figured i should try opening the file and read it's contents and then use parseString() instead of parseURL


         XMLfile = new xtra("FileIO")
         XMLfile.openFile(_movie.path&"inf.xml", 1)
         XMLdata = XMLfile.readFile()
         put XMLdata


      But the xml file is UTF-8 encoded and in the manual it says:

      "When reading UTF-8 or UTF-16 files using readFile(), the beginning of the file might not be retrieved as intended. To ensure proper reading, you must handle the BOM character in the script.For UTF-8 file the BOM character is EF BB BF.For UTF-16 file the BOM character is FF FE."

      It doesnt't give any more information on how to actually open this...