header
header
Main Menu
Home
Eviware Store
Downloads
Products
News
Forum
Eviware Blog
Search
FAQs
Customer Area
Support
Documentation
Tutorials
CookBook
Downloads
Forum
Login Form
Welcome, Guest. Please login or register.
January 09, 2009, 08:17:35 am
Username: Password:
Login with username, password and session length

Forgot your password?
 
[Urgent] Getting the child count for a node
Welcome, Guest. Please login or register.
January 09, 2009, 08:17:35 am
Home Help Search Login Register
News: The Forums are up! Welcome to eviware.

+  Eviware Forum
|-+  soapUI
| |-+  soapUI
| | |-+  [Urgent] Getting the child count for a node
« previous next »
Pages: [1] Print
Author Topic: [Urgent] Getting the child count for a node  (Read 606 times)
lakshmi
Newbie
*
Posts: 15


« 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
Logged
omatzura
Administrator
Hero Member
*****
Posts: 1,666


« Reply #1 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
Logged
lakshmi
Newbie
*
Posts: 15


« Reply #2 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


Logged
omatzura
Administrator
Hero Member
*****
Posts: 1,666


« Reply #3 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
Logged
lakshmi
Newbie
*
Posts: 15


« Reply #4 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
Logged
omatzura
Administrator
Hero Member
*****
Posts: 1,666


« Reply #5 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
Logged
lakshmi
Newbie
*
Posts: 15


« Reply #6 on: July 22, 2008, 12:38:07 pm »

Thanks again for the logic .It works just  fine  Smiley

Regards,
Lakshmi



Logged
Pages: [1] Print 
« previous next »
Jump to:  


Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
header header
header
header