[SR-Users] xmlops/xpath access of multiple nodes

Daniel-Constantin Mierla miconda at gmail.com
Mon Jan 30 20:15:45 CET 2012


Hello,

full xpath syntax should be exported, iirc, there is an xpath function 
named position() that can be used to build expression to select the 
desired note. perhaps googling this xpath function will reveal some 
examples/hints.

Cheers,
Daniel


On 1/30/12 3:28 PM, Alex Balashov wrote:
> Hi,
>
> I guess this is more of an xpath question than a Kamailio one, so 
> forgive me.  All the same, how does one deal with a document like this 
> using $xml(...):
>
> <?xml version="1.0" encoding="utf-8" ?>
> <sheep>
> <lamb>
>         ...
> </lamb>
> <lamb>
>         ...
> </lamb>
> </sheep>
>
> Specifically, how do I access the second, third, Nth element with the 
> same tag, but without knowledge of any unique identifying attributes? 
>  Is there a useful way to iterate through them in Kamailio route script?
>
> I would have thought something like this could work:
>
>    $var(i) = 0;
>
>    while(defined $xml(x=>xpath:/sheep/lamb[$var(i)])) {
>       ...
>       $var(i) = $var(i) + 1;
>    }
>
> However, obviously, that's not it.  So what's the right way to do it?
>
> My desire is to buffer data from these nodes into an AVP array.  As 
> you might guess, it's a route set over which I need to serially fork.
>
> Thanks!
>
> -- Alex
>

-- 
Daniel-Constantin Mierla -- http://www.asipto.com
http://linkedin.com/in/miconda -- http://twitter.com/miconda




More information about the sr-users mailing list