Please use the version that is now published in PharoExtras. If you add tests please commit them :)
On Feb 27, 2013, at 6:55 PM, Mariano Martinez Peck <[email protected]> wrote: > Hi guys. I am using XMLWriter from http://www.squeaksource.com/XMLWriter to > write a specific XML that a protocol expects. > What I need is to build the XML file from parent to children and dynamically. > For example, I want to be able to define a tag, but then, later on, add more > tags to a parent element. > I found this impossible to do with the current XMLWriter. Here, messages > like #tag:with: , #with: do not help. > I know I will need to build everything in memory and send a "write contents" > at the end to get the final XML string... > > For example, say I wanna build this XML: > > <root> > <parent1> > <child1>grrr<child1> > <child2>grrr<child2> > </parent1> > <parent2> > <child3>buhhh<child3> > </parent2> > </root> > > i would like an API like this: > > | xmlWriter | > xmlWriter := XMLWriter new. > xmlWriter tag: 'root'. > (xmlWriter named: 'root') tag: 'parent1'. > (xmlWriter named: 'parent1') tag: 'child' with: 'grrr'. > (xmlWriter named: 'root') tag: 'parent2'. > .... > xmlWriter write contents. > > > Or even if I don't have #named: but I can store them in instVars it would be > fine: > > | xmlWriter rootTag parent1Tag | > xmlWriter := XMLWriter new. > rootTag xmlWriter tag: 'root'. > parent1Tag rootTag tag: 'parent1'. > parent1Tag tag: 'child' with: 'grrr'. > rootTag tag: 'parent2' > xmlWriter write contents. > > > Any ideas how to do this? > > Thanks, > > -- > Mariano > http://marianopeck.wordpress.com
