You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Christian Migowski <ch...@gmail.com> on 2008/02/26 14:15:48 UTC

commons-configuration XMLConfiguration get attributes with XPathExpressionEngine

Hi,

how can I use XPathExpressionEngine to get a list of XML attributes? It
seems like i cannot get it working, here is an easily reproducable example.

Given the XML file simple.xml:
<?xml version="1.0" encoding="UTF-8"?>
<bsmpools>
<Pool id="eins">
 <Name>Name 1</Name>
</Pool>
<Pool id="zwei">
 <Name>Name 2</Name>
</Pool>
<Pool id="drei">
 <Name>Name 3</Name>
</Pool>
</bsmpools>


The code:
 XMLConfiguration config = new XMLConfiguration("simple.xml");
 config.setReloadingStrategy(new FileChangedReloadingStrategy());
 config.setExpressionEngine(new XPathExpressionEngine());
 List x = config.getList("/Pool[@id]");



x ist always empty... I would assume it to contain three elements "eins",
"zwei" & "drei". What am I doing/thinking wrong?

regards,
christian!


P.S. how can I search the maling list? The archive link from
http://commons.apache.org/configuration/mail-lists.html does not seem to
contain a searching functionalilty

Re: commons-configuration XMLConfiguration get attributes with XPathExpressionEngine

Posted by Christian Migowski <ch...@gmail.com>.
Hi Oliver,

2008/2/26, Oliver Heger oliver.heger@oliver-heger.de:


> The code:
> >  XMLConfiguration config = new XMLConfiguration("simple.xml");
> >  config.setReloadingStrategy(new FileChangedReloadingStrategy());
> >  config.setExpressionEngine(new XPathExpressionEngine());
> >  List x = config.getList("/Pool[@id]");
> >
> >
> >
> > x ist always empty... I would assume it to contain three elements
> "eins",
> > "zwei" & "drei". What am I doing/thinking wrong?
>
> Did you try
> List x = config.getList("/Pool/@id"); ?
>
> Something like this works in the unit tests.
>
> Oliver


 That worked. Thanks a lot!
best regards,
christian!

Re: commons-configuration XMLConfiguration get attributes with XPathExpressionEngine

Posted by Oliver Heger <ol...@oliver-heger.de>.
Christian Migowski schrieb:
> Hi,
> 
> how can I use XPathExpressionEngine to get a list of XML attributes? It
> seems like i cannot get it working, here is an easily reproducable example.
> 
> Given the XML file simple.xml:
> <?xml version="1.0" encoding="UTF-8"?>
> <bsmpools>
> <Pool id="eins">
>  <Name>Name 1</Name>
> </Pool>
> <Pool id="zwei">
>  <Name>Name 2</Name>
> </Pool>
> <Pool id="drei">
>  <Name>Name 3</Name>
> </Pool>
> </bsmpools>
> 
> 
> The code:
>  XMLConfiguration config = new XMLConfiguration("simple.xml");
>  config.setReloadingStrategy(new FileChangedReloadingStrategy());
>  config.setExpressionEngine(new XPathExpressionEngine());
>  List x = config.getList("/Pool[@id]");
> 
> 
> 
> x ist always empty... I would assume it to contain three elements "eins",
> "zwei" & "drei". What am I doing/thinking wrong?

Did you try
List x = config.getList("/Pool/@id"); ?

Something like this works in the unit tests.

Oliver

> 
> regards,
> christian!
> 
> 
> P.S. how can I search the maling list? The archive link from
> http://commons.apache.org/configuration/mail-lists.html does not seem to
> contain a searching functionalilty
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org