[jdom-interest] reading block of html in an xml file
Jason Hunter
jhunter at collab.net
Thu Apr 19 10:52:30 PDT 2001
philip.nelson at omniresources.com wrote:
>
> > I have an xml file where an element conatins some well formatted
> > html. At the moment I comment out the html so as I can read the
> > block of html in one go.
> >
> > <site id="">
> > <header><!-- well formatted html --></header>
> > </site>
>
> Sure, though not exactly as you might expect. You would build the Document,
> get the header element. Then, if you could live with <header> as part of
> the the string just use XMLOutputter and output the element to a
> StringWriter. Otherwise, you will get the header content loop through it
> and successively write each element to the same StringWriter.
There's actually an XMLOutputter.outputElementContent() method to make
this easy and automatic. Call it on your <header> and you get
everything within but not the <header> tags. Note that it follows the
configuration you make on XMLOutputter regarding indent, new lines, text
trimming, etc. That's why it's a method of the outputter and not
Element, it's very configurable.
-jh-
More information about the jdom-interest
mailing list