I still do not know how to do this correctly. But I have something that seems to work for the moment.

Using #asUTF8Bytes

f nextPutAll: (writer write contents asUTF8Bytes).

Now the file is in UTF-8 and normal size.


Jimmie


On 09/13/2017 12:02 PM, Jimmie Houchin wrote:
Hello,

I am attempting to read and write an XML document.

Currently I have parsed the document successfully. I have basic navigation and have learned how to modify the XMLDocument.

Now I want to write the modified document back to the file system.
What I have tried so far is:

writer := XMLWriter new.
xmldoc document writeXMLOn: writer.
writer stream.
f := File openForWriteFileNamed: '/home/jimmie/xmldoc.xml'.
f nextPutAll: (writer write contents).
f flush.
f close.

It does write an xml document to the file system. However, it has exploded in size. The original is 28mb and is in UTF-8. The newly written file is 112mb and is UTF-32.

I do not know why the change in encoding or how to correct or manually set the encoding.

Any help in understanding how to correctly write an XML document that I have read and minimally modified would be greatly appreciated.

Thanks.

Jimmie




Reply via email to