> > From: Fred Meredith [mailto:[EMAIL PROTECTED]]
> > Sent: Thursday, January 24, 2002 5:16 PM
> >
> > I'd use a StringBuffer object to build the XML string the way
> > you need it to
> > be and then do something like this:
> >
> > DocumentBuilder xdb = XMLParserUtils.getXMLDocBuilder();
> > Document doc = xdb.parse(new InputSource(new
> > StringReader(stringBuffer.toString())));
> > Envelope env = Envelope.unmarshall(doc.getDocumentElement());
> >
>
> Correct me if I'm wrong, but you seem to be saying:
>   Build it as a string.
>   Parse it.
>   Unparse it.
>
> That doesn't seem right.  One may as well just insert the string into the
> envelope directly.
>
> If you want to build a DOM version, doesn't it make more sense to build it
> directly, instead of building the string and parsing it?
>
> Gary

 Consider the above a generic example...
Instead of building a string to parse, I could have just as easily read the
XML structure from a file by using the line: Document doc = xdb.parse(new
InputSource(new FileReader(filename)));

Yes, if I wanted to build a DOM structure and knew the string values to
build into it, it definitely would make more sense to do it that way.  You
are correct, Gary.

I'm not aware of any direct method that will allow creating an Envelope
object directly from an input string... is there a way?  I've always done it
as above; if there's a better way, I'd love to know.




Reply via email to