[jdom-interest] Need for a SAXBuilder.build(String XMLString) method?

Raffaele Sena raff at aromatic.org
Sun Apr 15 22:45:17 PDT 2001


> I may have missed something,but as far as I can tell, there doesn't seem to
be any
> capability for the build() methods of both SAXBuilder and DOMBuilder classes
to
> build documents directly from Strings declared from within the program.
>
> Does anyone else out there think that this might be useful?
>
> For myself, I can see that this would be helpful in writing JUnit tests  for
more
> simple
> cases.  Instead of having to read in from an external file, the whole XML
document
> could simply be contained inside a String declared inside the program.
>
    One of the build methods accepts in input a java.io.Reader object,
    and you can use a java.io.StringReader object to pass your string as
input:

        String xmlInput =
"<root><child>hello</child><child>there</child><child/></root>";
        SAXBuilder build = new SAXBuilder();
        Document document = builder.build(new StringReader(xmlInput));

    (I didn't try this, I am just looking at the documentation and writing
    it down).

-- Raffaele

-----------------------------------------------------
raff at aromatic.org (::) http://www.aromatic.org/~raff/

When I say artist I mean the man who is building things
 -- creating molding the earth -- whether it be the plains of the west
 -- or the iron ore of Penn. It's all a big game of construction
 -- some with a brush -- some with a shovel -- some choose a pen.

                             Jackson Pollock




More information about the jdom-interest mailing list