commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject Re: [Digester] - how to Parse Tag attributes and tag content with addObjectCreate and CallMethod...
Date Wed, 14 Apr 2004 11:44:10 GMT
Thanks for the feedback.

Unfortunately, there is not a lot I can do about the XML, which is from a public site.

I have solved the problem, but not quite with the mechanisms you suggest.

For the XML:
      <Item Name="forProperty" Type="String">This is the 
      <Item Name="forAnotherProperty" Type="String">More 

I used this:

	digester.addObjectCreate("root", root.class);
	digester.addBeanPropertySetter("root/subsection/Id", "id");
	digester.addObjectCreate("root/subsection/Item", Item.class); 
	digester.addSetProperties("root/subsection/Item", "Name", "name");
	digester.addSetProperties("root/subsection/Item", "Type", "type");
	digester.addSetNext("root/subsection/Item", "addItem" );
	digester.addCallMethod("root/subsection/Item", "addItemValue", 0); 
	digester.addSetNext("root/subsection", "addSubsection");

which seems to do the job of parsing, so that I have a root of subsections, each 
subsection containing items; each item has a list of 'properties' [name] with values 
corresponding to the tag 'content'.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message