2012年4月9日 星期一

[Java] More on commons.configuration

XML Configuration: (notification.xml)
<?xml version="1.0" encoding="UTF-8"?>

<config>
    <notification>
        <server>Server1</server>
        <server>Server2</server>
    </notification>
</config>

For example, we have two servers in the config file. How to we retrieve them?
List<Object> serverList = config.getList("notification.server");
for (Object server : serverList) {
    // (String)server;
}

沒有留言:

張貼留言