cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Giacomo Pati <Giacomo.P...@pwr.ch>
Subject Re: parse XML String in java code
Date Thu, 13 Apr 2000 21:20:06 GMT
rong wrote:
> 
> Hi,
> 
> If i want to parse a String(in a piece of java code), which is in form of
> XML document, what should i do? The String can be in form of:
> 
> String s1 = " <POEM> <AUTHOR> Ogden Nash </AUTHOR> <TITLE> Fleas
</TITLE>
> <LINE> Adam had'em. </LINE></POEM> ";
> 
> In SAXParser, the function:
> 
>  Parser parser = ParserFactory.makeParser("com.ibm.xml.parsers.SAXParser");
>  parser.setDocumentHandler(titleFinder);
>  parser.parse(new InputSource(args[0]));

Use: parser.parse (new InputSource (new StringReader (s1));

Giacomo

> 
> can take an instance of File class(args[0]="*.xml") and parse it according
> to an instance usr-defined class(titleFinder). This method basically parse
> a xml file, not a String in the code.
> 
> Is there a way to parse a XML String in cocoon or another way?
> 
> Thanks,
> 
> Rong

-- 
PWR Organisation & Entwicklung            Tel:   +41 (0)1 856 2202
Giacomo Pati                              Fax:   +41 (0)1 856 2201
Hintereichenstrasse 7                     Mailto:Giacomo.Pati@pwr.ch
CH-8166 Niederweningen                    Web:   http://www.pwr.ch

Mime
View raw message