2010/8/1 Charles Wel <charlemagne / welnowiec.net>:
> Hello All,
>
> I have an XML file containing this
> <properties>
> =A0 =A0<property key=3D"ABC">
> =A0 =A0 =A0 =A0<value xml:lang=3D"de">Description de</value>
> =A0 =A0 =A0 =A0<value xml:lang=3D"en">Description en</value>
> =A0 =A0</property>
> =A0 =A0<property key=3D"XYZ">
> =A0 =A0 =A0 =A0<value xml:lang=3D"de">Description de</value>
> =A0 =A0 =A0 =A0<value xml:lang=3D"en">Description en</value>
> =A0 =A0</property>
> </properties>
>
> I made a code to add a new <value> tag to each <property>.
> The part of code is:
>
> require "rexml/document"
> include REXML
> ...
> ...
> =A0 =A0 =A0pval =3D Element.new("value")
> =A0 =A0 =A0pval.add_attribute("xml:lang","fr")
> =A0 =A0 =A0pval.add_text("Description fr")
> =A0 =A0 =A0fproperty.elements << pval
> fproperty is the node object
>
> My final XML file looks like this:
>
> <properties>
> =A0<property key=3D"ABC">
> =A0 =A0<value xml:lang=3D"de">Description de</value>
> =A0 =A0<value xml:lang=3D"en">Description en</value>
> =A0 =A0<value xml:lang=3D"fr">Description fr</value></property>
> =A0<property key=3D"XYZ">
> =A0 =A0<value xml:lang=3D"de">Description de</value>
> =A0 =A0<value xml:lang=3D"en">Description en</value>
> =A0 =A0<value xml:lang=3D"fr">Description fr</value></property>
> </properties>
>
> One "TAB" is inserted for each 4 spaces which were in the original file.
> How to avoid this?
> And how to add a CR to the new element?
>
> Thanks for your help, I'm a very newby

I think, you will have to create your own formatter - or use a
different one for output.  You'll find some explanation in the REXML
documentation.

Kind regards

robert


--=20
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/