Get specific XML Subvalues with Commons Configuration

Lets say we have the following XML:

<root>
    <sub>
        <id>1</id>
        <values>
            <value>1</value>
            <value>2</value>
        </values>
    </sub>
    <sub>
        <id>2</id>
        <values>
            <value>16</value>
            <value>15</value> 
        </values>
    </sub>
</root>

What I want to with Apache Commons Configuration: I want to get all values for sub with id2. How could I achieve that? I find nothing in the documentation, how I can query with a dynamic hierarchy number.

Answers


You can use XPath:

//sub[id = 2]/values/value

Need Your Help

I want to echo __FILE__ name without path. I just want to name of page for example: index.php

php path filenames

echo __FILE__; gives me: C:\EasyPHP-DevServer-13.1VC9\data\localweb\projects\FOLDERNAME\index.php I just want to get file name without its path. I want to get index.php on its own. Any ideas?

Set Delegate for Subview Controller

ios objective-c uitableview cocoa-touch delegates

i'm sure there is a simple way to solve this problem, but I can't figure out.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.