commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simon Kitching <skitch...@apache.org>
Subject Re: [Digester] Parse an Element containing random data
Date Mon, 23 Jan 2006 22:55:42 GMT
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