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.child.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")
XMLdata = XMLfile.readFile()
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...
Try loading simpler XML first, like this one:
<Char1 text = "Hello world."/>
You should not have any problem parsing the strings from this one. Good luck.
objXML = new xtra("xmlparser")
objFileIO = new xtra("fileio")
put(objFileIO.fileName()) -- will return void if file not found
file_data = objfileio.readfile()
errorcode=objxml.parsestring(file_data) -- will return void if no error found parsing the strings
put objxml.child.name -- then you can try slowly approach the xml's nodes and see if you're doing it right