And in case anyone is not aware, this video shows how to manipulate xml:

http://www.pharocasts.com/2010/08/see-how-to-get-data-from-url-parse-xml.html


2013/2/27 Sven Van Caekenberghe <[email protected]>

>
> On 27 Feb 2013, at 22:17, stephane ducasse <[email protected]>
> 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
>
> Here are two approaches that seem to work fine:
>
> | 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 |
>         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 := (XMLDOMParser parse: xmlWriter contents).
> 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" <[email protected]>
> 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
> >>
> >
>
>
>

Reply via email to