commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nikolay Georgiev" <ngeorg...@gistec-online.de>
Subject AW: [Digester] Parse an Element containing random data
Date Thu, 26 Jan 2006 13:45:19 GMT
Thanks,

wrapping it in a CDATA section works great :)

Regards,
Nikolay

-----Urspr√ľngliche Nachricht-----
Von: Simon Kitching [mailto:skitching@apache.org]
Gesendet: Montag, 23. Januar 2006 23:56
An: Jakarta Commons Users List
Betreff: Re: [Digester] Parse an Element containing random data


On Mon, 2006-01-23 at 16:24 +0100, Nikolay Georgiev wrote:
> Hello,
>
> can I make the Digester to parse an XML element that contains random
> data(characters, say HTML code) from it's beginning to it's end and then
> save the data in a string.
>
> For example:
>
> <section>
> 	<text>
> 		I want to save this text with these tags <b>as a String Object</b>. <br
/>
> 	</text>
> </section>
>
> Is it possible?

Digester takes its input from an XML parser, and there is no way to tell
an XML parser to "stop treating the input as xml for a while" - except
by wrapping the input in CDATA.

If your input was:
 <text>
<![CDATA[
  ....<b>...</b>...<br/>
]]>
 </text>

then everything would work as you want. This is the correct way to
represent arbitrary text embedded within an xml document.

If the content is valid XML, then you could use NodeCreateRule to turn
the content of the <text> element into a dom tree, then walk that tree
to turn it back into text.

Regards,

Simon


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message