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.
December 01, 2008, 06:50:53 pm
Username: Password:
Login with username, password and session length

Forgot your password?
 
xpath and getNodeValues
Welcome, Guest. Please login or register.
December 01, 2008, 06:50:53 pm
Home Help Search Login Register
News: The Forums are up! Welcome to eviware.

+  Eviware Forum
|-+  soapUI
| |-+  soapUI
| | |-+  xpath and getNodeValues
« previous next »
Pages: [1] Print
Author Topic: xpath and getNodeValues  (Read 441 times)
John R. Brewster
Newbie
*
Posts: 10


« on: August 25, 2008, 06:37:11 pm »


Greeting,

How would I use getNodeValues if I was to get multiple nodes.

for example:

<baz>
  <foo>
    <bar>this is a test</bar>
  </foo>
  <foo>
    <bar>Yet another test</bar?
  </foo>
</baz>

If I use:
def holder = groovyUtils.getXmlHolder( "Book Author Search#Response" )
bartest = holder.getNodeVales ( "//bar" );


I can only update the FIRST bar!  I have multiple "bar" that I need to update.  How can I get to the others?

I read in the docs "If the specified XPath expression returns multiple values when getting a value, a String array is returned instead:"  So, I get a string.  I need the reference to the holder for each bar

or, am I thinking wrong?

JOhn
Logged
omatzura
Administrator
Hero Member
*****
Posts: 1,466


« Reply #1 on: August 26, 2008, 09:36:01 pm »

Hi John,

please try using holder.getDomNodes( xpath ) instead which should return a list of DOM nodes that you can then use for modification..

makes sense?

regards!

/Ole
eviware.com
Logged
John R. Brewster
Newbie
*
Posts: 10


« Reply #2 on: August 27, 2008, 01:25:12 am »

YEs,

I just have to comb thru the API to figure out what to use to update.

Thanks, let me run with that and see what happens.

J
Logged
omatzura
Administrator
Hero Member
*****
Posts: 1,466


« Reply #3 on: August 27, 2008, 10:45:40 am »

Ok!

you can use XmlUtils.setNodeValue( node, "..." ) to set the text content of either an attribute or an element..

regards,

/Ole
eviware.com
Logged
John R. Brewster
Newbie
*
Posts: 10


« Reply #4 on: August 27, 2008, 08:14:01 pm »


Well, that made it slap easy.

def _xmlUtil =      new com.eviware.soapui.support.xml.XmlUtils();

...

newNode = holder.getDomNodes ( "//aps:Value" );

for ( i in newNode ) {
      _xmlUtil.setNodeValue(i, "newValue");
}
holder.updateProperty()

It was the XmlUtils that I didn't know about.  Thanks for your help!!

John
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