开发者

Java, Apache Commons Configuration XML attributes

开发者 https://www.devze.com 2023-03-08 02:17 出处:网络
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:

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号