I try to write an xml object via AIR with FileStream.writeObject
I’m doing like this:
var _file:File = File.applicationDirectory.resolvePath("test.xml");
var _xml:XML = new XML("<data><name>Testname</name><email>test@test.de</email><time>1331290186848</time></data>");
stream = new FileStream()
stream.open(_file, FileMode.WRITE);
stream.writeObject(xml);
stream.close();
unfortunately, this is the result
Å<data>
<name>Testname</name>
<email>test@test.de</email>
<time>1331290186848</time>
</data>
since i don’t have any influence on the process, how can i prevent AIR to write those strange chars?
thank you!
You should write your XML to the file as a String. Right now you’re writing it as an XML object, which looks a lot like a String, but has some additional information. I think that strange character at the start represents the length of the String.
Use writeUTFBytes() instead of writeObject().
So replace
with
writeUTF() won’t do the trick either: if you read the docs, you’ll see that it writes the length of the String as the first character too.