And in case anyone is not aware, this video shows how to manipulate xml:
Here are two approaches that seem to work fine:
On 27 Feb 2013, at 22:17, stephane ducasse <stephane.ducasse@free.fr> wrote:
> +1
>
> Mariano I'm about to migrate the XMLParser to SmalltalkHub and I know that you have a DOMTree and a saxAPI
> So with the DOMTree I do not see why we could not manipulate the tree.
>
> Stef
| dom |
dom := (XMLDOMParser parse: '<foo><bar>text</bar><baz>100</baz></foo>').
dom firstElement addNode: ((XMLElement named: 'mariano') addContent: 'Hi there !' ).
dom prettyPrinted.
| xmlWriter dom |
xmlWriter := XMLWriter new writeWith: [ :writer |dom := (XMLDOMParser parse: xmlWriter contents).
� � � � writer
� � � � � � � � enablePrettyPrinting;
� � � � � � � � xml;
� � � � � � � � comment: 'Generated from Pharo.'.
� � � � writer tag: 'root' with: [
� � � � � � � � writer tag: 'parent1' with: [
� � � � � � � � � � � � writer tag: 'child1' with: 'grrr'.
� � � � � � � � � � � � writer tag: 'child2' with: 'grrr' ].
� � � � � � � � writer tag: 'parent2' with: [
� � � � � � � � � � � � writer tag: 'child3' with: 'buhhhr' ] ] ].
dom firstElement addNode: ((XMLElement named: 'mariano') addContent: 'Hi there !' ).
dom prettyPrinted.
I guess it would also be possible to completely construct the DOM tree manually.
Regards,
Sven
>> On 27 Feb 2013, at 21:18, "Esteban A. Maringolo" <emaringolo@gmail.com> wrote:
>>
>>> To do what he wants he should have an XML DOM and manipulate the DOM
>>> nodes directly. I don't know if we have such thing in Pharo.
>>
>> I would be very surprised if that were not possible: create a DOM tree, either manually or by parsing some XML, then add some nodes and finally render it again.
>>
>> I never did this, but I'll have a look if I have some time.
>>
>> Sven
>>
>>
>> --
>> Sven Van Caekenberghe
>> http://stfx.eu
>> Smalltalk is the Red Pill
>>
>