Thank you all guys. Indeed, it was quite possible to manually build the DOM.
I was confused because the package was called "XMLParser". I could see the nodes and all the DOM but I didn't expected these classes would understand "writing behavior" like #named: , #add: etc... but yes, they do understand so you can manually build the DOM and when you are done you can just get the resulting string.�

Best,�

On Thu, Feb 28, 2013 at 12:50 PM, stephane ducasse <stephane.ducasse@free.fr> wrote:
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 <marianopeck@gmail.com> 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




--
Mariano
http://marianopeck.wordpress.com