making Elements from strings

Hi, 

Is there a way of taking a string which is an XML element (perhaps with many
other elements nested within it), and directly creating from it an Element
belonging to an already existing Document?

At present, to create an Element belonging to Document, doc, from such a
string, I  go through the following steps (I'm using XML4J):

- append "<?xml version=\"1.0\"?>" to the front of the string
- call org.apache.xerces.parsers.DOMParser to create a temporary document
from the string (wrapped in an InputSource)
- cast doc to DocumentImpl
- call importNode on the DocumentImpl, passing it the document element of
the temporary document,
     thus creating an equivalent Element which is owned by doc.

The creation of the temporary document seems to be a a waste of time and
space. Instead, what I'd like to be able to do is parse  the string straight
into an Element belonging to doc.  Are there any XML parsers which do this?
Is there any way of getting DOMPaser to do this? Is there any reason in
principle why this is not possible?

Thanks for any advice on this, 

David Pickles

Received on Tuesday, 22 August 2000 11:11:41 UTC