cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeremy Quinn <jer...@media.demon.co.uk>
Subject Re: DOM
Date Sat, 02 Sep 2000 11:24:39 GMT
At 15:38 -0300 01/09/00, Alejandro Raiczyk wrote:
>Hey people, how can I create a DOM from a XML file ?
>I mean, I need something like:
>
>        Document D = CreateDOM("file.xml")
>
>Thanks!

This is how I believe you do it (from within the populateDocument Method).

This code could be either in your XSP user-root, your TagLib logicSheet or
TagLib support library. This example shows it in your XSP.


<xsp:logic>
private Element parseFile(DOMParser parser, String file){
	Document doc = null;
	try{
		doc = parser.parse(new InputSource("file:" + file));
	} catch (SAXException pe) {
		// parse error
	} catch (java.io.IOException fe) {
		// file error
	}
	if (doc != null) {
		return doc.getDocumentElement();
	}
	return null;
}
</xsp:logic>


<xsp:expr>parseFile(this.xspParser, "file.xml")</xsp:expr>




Someone please correct me if I am wrong :)

hope this helps

regards Jeremy
-- 
   ___________________________________________________________________

   Jeremy Quinn                                           Karma Divers
                                                       webSpace Design
                                            HyperMedia Research Centre

   <mailto:sharkbait@mac.com>     		 <http://www.media.demon.co.uk>
    <phone:+44.[0].20.7737.6831>        <pager:jermq@sms.genie.co.uk>

Mime
View raw message