Re: parse using DOM

Subject: Re: parse using DOM
From: Warren Hedley <w.hedley@xxxxxxxxxxxxxx>
Date: Thu, 03 Feb 2000 09:49:50 +1300
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


Current Thread