I'm reading config from an XML file using Apache's commons.configuration. In one of the sections开发者_开发问答, I have several lines in the form of:
<bla attr1="something" attr2="something else" />
Ideally, I would like to do something like this:
List blas = config.getList("section.bla");
String attr1 = blas.get(0).getAttribute("attr1");
(The code above does not work, obviously)
Is this possible somehow, or do I have to query each attribute separately in the XPath-like notation, iterating myself through the list?
I think this is what you are looking for:
http://commons.apache.org/proper/commons-configuration/userguide-1.2/howto_xml.html
It would be something like this:
config.getString("bla(0)[@attr1]")
Well, I ended up manually iterating and querying for everything separately.
精彩评论