Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Jakarta-commons Wiki" 
for change notification.

The following page has been changed by SimonKitching:
http://wiki.apache.org/jakarta-commons/Digester/FAQ

The comment on the change is:
Add info about extracting nested XML as a string

------------------------------------------------------------------------------
  
  It might be possible to create a custom "filtering" rule that has a child 
rule,
  and fires that child rule only when the appropriate conditions are set. There
- are no examples of such a solution, however.
+ are no examples of such a solution, however. 
  
  A possible solution is to perform an XSLT transform to filter out or rename 
elements that
  match certain conditions before using Digester to process the document. 
@@ -422, +422 @@

  
  If you are aware of other solutions to this issue, please add that 
information here.
  
+ == How do I get some xml nested within a tag as a literal string? ==
+ 
+ It is frequently asked how some XML (esp. XHTML) nested within a document can 
be extracted
+ as a string, eg to extract the contents of the "body" tag below as a string:
+ 
+ {{{
+   <article>
+     <title>An article about something</title>
+     <body>
+       <p>Some xhtml data</p>
+       <p>Some more xhtml data</p>
+     </body>
+    </article>
+ }}}
+ 
+ If you can modify the above to wrap the desired text as a CDATA section then 
things are easy; Digester will simply treat that CDATA block
+ as a single string:
+ 
+ {{{
+   <article>
+     <title>An article about something</title>
+     <body>
+       <![CDATA[
+       <p>Some xhtml data</p>
+       <p>Some more xhtml data</p>
+       ]]>
+     </body>
+    </article>
+ }}}
+ 
+ If this can't be done then you need to use a !NodeCreateRule to create a DOM 
node representing the body tag and its children, then
+ serialise that DOM node back to text.
+ 
+ Remember that Digester is just a layer on top of a standard XML parser, and 
standard XML parsers have no option to just stop parsing
+ input at a specific element - unless it knows that the contents of that 
element is a block of characters (CDATA).
+ 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to