On Tue, 2007-07-31 at 13:49 +0200, Amit wrote: > Hi All, > > I am parsing an xml file using digester. This xml file has structure as > follows > > <parents> > <parent id = 1> > <child1></child1> > <child2></child2> > </parent> > <parent id = 2> > <child1></child1> > <child2></child2> > </parent> > </parents> > > This xml file would have many parent elements, but with unique ids. I want > to know if I can query such an xml file by id and get only the parent with > the queried id..? > If yes kindly give me a hint or a small example. > Any help appreciated.
Digester is not an xml "query tool", like xpath. Digester is a library that makes handling SAX parse events easier. You feed an xml document into a sax parser, and it sends events (like "start of tag child2") to digester which then consults its configured rules to determine what java objects to instantiate or what java methods to call. In particular, Digester makes it easy to build a tree of java objects that represent the data in the xml file. If you really want to just find certain elements in an xml file, I suggest you investigate the standard xpath support in standard package javax.xml.xpath (java 1.5 and later). Regards, Simon --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
