links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
Writing and reading an XML file
Last updated at 7:34 pm UTC on 15 September 2017

Writing an XML file

 doc := XMLDocument new.
 stream := FileStream fileNamed: 'MyXml.xml'. "specify the stream"
 writer := XMLWriter on:stream. "specify the writer"
 writer initialize.
 "Code below describes how you could write an xml element with a tag "
 elmt := XMLElement named: 'user' attributes: Dictionary new.
 "add the attribute tags and values to the "
 childElmt := XMLElement named: 'name' attributes: Dictionary new.
 childElmt addContent: (XMLStringNode string: ('rao')). "adding a tag called Name with the value 'rao'"
 elmt addElement: childElmt.
 doc addElement: elmt.
 doc printXMLOn: writer.
 stream close.

Produces the following file


Read this file

See also