You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xml.apache.org by Ahmad Morad <mo...@ibiza.db.informatik.uni-kassel.de> on 2000/11/30 13:15:28 UTC
DocumentBuilder.parse()
Hello xalan's,
With the following code I read an XML-Document from an �InputSource� <from>
and store it in a �Document� object using the DocumentBuilder.parse()
method. However the InputSource <from> is the InputStream of a socket.
the parse method close the stream after reading the document! This well
close the connection to the server !
The only way I know to avoid that is to read the document in a string and to
call the parse method to read the string in a dom tree. But this sulution
is very slow!
how can I avoid the parser from closing the stream after the parse process
has been finished ?
Than you
Morad Ahmad
code :
--
DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = dfactory.newDocumentBuilder();
Document doc = docBuilder.parse(from); // after that from well be closed
return doc;
--