Eviware Forum

soapUI => soapUI => Topic started by: lakshmi on July 16, 2008, 07:30:55 am



Title: [Urgent] Getting the child count for a node
Post by: lakshmi on July 16, 2008, 07:30:55 am

Hello

I would like to find out how to get the children count for a node
given the xpath like expression. I am using groovy as scripting lang.

The problem is that I only have the xpath expression. I am not sure
how to get node representing path and hence size or children count.

Any help over here asap is appreciated.

Thanks,
Lakshmi


Title: Re: [Urgent] Getting the child count for a node
Post by: omatzura on July 16, 2008, 07:43:38 am
Hi,

can you show the XML explain exactly what you want to count?

regards!

/Ole
eviware.com


Title: Re: [Urgent] Getting the child count for a node
Post by: lakshmi on July 16, 2008, 09:42:05 am
Hi

Below is the structure of the response xml that i am trying to parse

-s:envelop
-s:body
  -AA
  -BB
    -CC
      -DD1
         @x: value1
         y : value2
         z : value3
        .
        .
       -DD2
         .
         .
         .
         .
       -DD3
          .
          .
      -DD(n)
   
    -EE1
      -FF1
      -CC
        -DD(n+1)
          @a :value4
          a  :value5
          .     
          .


I am trying to capture the "values." of the individual node elements by looping,but am not sure how to get the children count for node given the x path like expression

here's a sample xpath expression
def hold = "//ns1:CC["+x+"]

where x is a running number.

Basically i need to get a child count for a Node but i only have the x path expression with me.Not sure how to proceed further.

Thanks,
Lakshmi




Title: Re: [Urgent] Getting the child count for a node
Post by: omatzura on July 17, 2008, 10:20:09 am
Hi Lakshmi,

try first getting the number of CCs with

def cnt = holder["count(//ns1:CC)"]

and then using the cnt in a loop!?

regards,

/Ole
eviware.com


Title: Re: [Urgent] Getting the child count for a node
Post by: lakshmi on July 21, 2008, 07:41:52 am
Hi Thanks for your reply,

We have another problem though.
We need to walk the tree in the right order.So can you please tell us how to get the separate counts for CC with respect to its two different parents namely BB and EE1

Thanks,
Lakshmi


Title: Re: [Urgent] Getting the child count for a node
Post by: omatzura on July 21, 2008, 10:46:07 pm
Hi,

try

def cntBB = holder["count(//ns1:BB/ns1:CC)"]
def cntEE1 = holder["count(//ns1:EE1/ns1:CC)"]

?

/Ole
eviware.com


Title: Re: [Urgent] Getting the child count for a node
Post by: lakshmi on July 22, 2008, 12:38:07 pm
Thanks again for the logic .It works just  fine  :)

Regards,
Lakshmi