PDA

View Full Version : Why use parseXML?



NickZA
June 29th, 2007, 05:04 AM
Hi

I'm a little confused about using XMLparse.

I'm making use of Zinc to write out to an XML file, but I don't know if it is actually necessary to parse the XML before writing the characters out to file... :h:

Because it seems to me like it'll make no difference whatsoever -- I can send out the XML unparsed, and as long as I do it right, there'll be no errors, right? It'll be just the same?

Perhaps there's something I don't understand here - if so please clarify for me.

I found an article at http://www.communitymx.com/content/article.cfm?cid=107B6 with the following code showing how it's done, but it looks as if I could just put the string in directly since it simply converts the XML object to a string anyway...? Here is the code:


import mdm.FileSystem;

var xml:XML = new XML();
xml.parseXML("<data>sample data</data>");

var filePath:String = FileSystem.getCurrentDir() + "sample.xml";
FileSystem.saveFile(filePath, xml.toString());Thank you. Here is a spotted egg for your trouble. :egg:

-Nick

senocular
June 29th, 2007, 07:46 AM
If you're not working with that XML data in Flash, then you don't need to parse it. You can just keep it as a string and send that to saveFile as a string.

NickZA
June 29th, 2007, 08:13 AM
Thanks for that Senocular!

Love your work by the way, though a lot of it is over my head.

Guess I must just have less eyes than you... :3ye:

-Nick