juef
06-04-2007, 08:31 PM
Hi all,
I'm a newbie to both XML and Java, but so far I'm doing OK. However, I would need some help with the following: let's say I have a XML file with a structure that looks like this:
<config>
<shop>
<name>Bob's tools</name>
<item>DVD player</item>
<item>Baseball bat</item>
</shop>
<shop>
<name>Another shop</name>
<item>LCD monitor</item>
<item>CRT monitor</item>
<item>Surround speakers</item>
<item>Keyboard</item>
</shop>
</config>
I have no trouble getting a list of the names of the shops with getList, but I have not been successful in obtaining the list of items for each shop (using Java). Is there an easy way of doing this? Would it be easier with attributes, or perhaps another kind of structure? I'm using these packages (see below), but I wouldn't mind using other ones.
import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.XMLConfiguration;
import org.apache.commons.configuration.AbstractConfiguration;
Thank you!!!
I'm a newbie to both XML and Java, but so far I'm doing OK. However, I would need some help with the following: let's say I have a XML file with a structure that looks like this:
<config>
<shop>
<name>Bob's tools</name>
<item>DVD player</item>
<item>Baseball bat</item>
</shop>
<shop>
<name>Another shop</name>
<item>LCD monitor</item>
<item>CRT monitor</item>
<item>Surround speakers</item>
<item>Keyboard</item>
</shop>
</config>
I have no trouble getting a list of the names of the shops with getList, but I have not been successful in obtaining the list of items for each shop (using Java). Is there an easy way of doing this? Would it be easier with attributes, or perhaps another kind of structure? I'm using these packages (see below), but I wouldn't mind using other ones.
import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.XMLConfiguration;
import org.apache.commons.configuration.AbstractConfiguration;
Thank you!!!