Oliver, I apologize for my incomplete snippet. Looking back it would be difficult to track down what was going on. So lets try this one more time with some complete code. :-)
XML Configuration Used: <?xml version="1.0" encoding="UTF-8" ?> <CollectiveVerificationTool> <Topic>test</Topic> <Publication> <Username>user</Username> <Password>usertest</Password> </Publication> <Hosts> <Subscribers>node1</Subscribers> <Publishers>node3</Publishers> </Hosts> </CollectiveVerificationTool> Here is a sample class illustrating the issue: import java.util.Arrays; import org.apache.commons.configuration.Configuration; import org.apache.commons.configuration.XMLConfiguration; public class ConfigTest { public ConfigTest() throws Exception { XMLConfiguration config = new XMLConfiguration( "CVT.xml" ); config.setValidating( false ); config.load(); Configuration subConfig = config.subset( "Hosts" ); System.out.println(subConfig.getString( "Subscribers" )); System.out.println(Arrays.asList(subConfig.getStringArray( "Subscribers" ))); } /** * @param args */ public static void main(String[] args) throws Exception { new ConfigTest(); } } Here is the output: node1 [node1, node1] I would expect the following output from that code above: node1 [node1] In other words I would expect a one element array returned by getStringArray and the contents of that string array being "node1". Thanks! On 1/18/07, Oliver Heger <[EMAIL PROTECTED]> wrote:
Brian O'Connell wrote: > I searched the archives (the best I could) but was unable to locate a > solution to this problem. > > I am using commons configuration 1.3 > > I am seeing duplicate entries using the getStringArray method with an > XMLConfiguration. > > Here is an example configuration file: > > <?xml version="1.0" encoding="UTF-8" ?> > <CollectiveVerificationTool> > <Topic>test</Topic> > > <Publication> > <Username>user</Username> > <Password>usertest</Password> > </Publication> > > <Hosts> > <Subscribers>node1</Subscribers> > <Publishers>node3</Publishers> > </Hosts> > > > </CollectiveVerificationTool> > > > Here is a code snippet that experiences the problem. > > > String single = configuration.getString( key ); > > System.out.println(single); > > String value[] = configuration.getStringArray( key ); > > System.out.println("Size of Array: " + value.length); > > System.out.println(Arrays.asList(value)); Sorry, but from this snippet I cannot track down the problem. Which value has the key variable? How did you load the configuration? Oliver > > > Here is the output of that snippet: > > node1 > Size of Array: 2 > [node1, node1] > > > I would expect the size of the array to be 1 and the only item to be a > single entry of node1. > > Any pointers are appreciated. > > Thanks! > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]