This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: parse using DOM
- To: xsl-list at mulberrytech dot com
- Subject: Re: parse using DOM
- From: Warren Hedley <w dot hedley at auckland dot ac dot nz>
- Date: Thu, 03 Feb 2000 09:49:50 +1300
- Organization: Department of Engineering Science, The University of Auckland
- References: <NDBBICIANKAGJHIJIGFJCEKGCHAA.paul.beer@backsoft.com>
- Reply-To: xsl-list at mulberrytech dot com
Try
String filename = "foo.xml";
DOMParser parser = new DOMParser();
FileInputStream fileStream = new FileInputStream(filename);
InputSource inputSource = new InputSource(fileStream);
inputSource.setSystemId("file:" + filename);
parser.parse(inputSource);
Document fdoc = parser.getDocument();
fileStream.close();
The InputSource class (see API docs for more info) contains a reference
to the incoming data stream and is used to store some information about
the file's role and location. Calling "setSystemId()" is critical for
most parsers if we want to be able to locate DTDs or external entities
that are referenced with relative URIs.
Hope this helps.
--
Warren Hedley
Department of Engineering Science
Auckland University
New Zealand
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list