Questions tagged [gpath]

Path expression language integrated into Groovy which allows parts of nested structured data to be identified. Can be used to query XML and nested Plain Old Java Objects

An overview of GPath with some sample code can be found on the codehause.org site

http://groovy.codehaus.org/GPath

79 questions
2
votes
1 answer

Find maximum value of attribute with Groovy XmlSlurper

Given xml: dt
lospejos
  • 1,976
  • 3
  • 19
  • 35
2
votes
2 answers

groovy Print path and value of elements in xml

I have the following xml: 2012 GM I want to print these values as path:value as shown below. list/cars/model : 2012 list/cars/make : GM How can I achieve this? I…
Bharath Reddy
  • 301
  • 2
  • 4
  • 15
2
votes
1 answer

Double slash in GPath expression

In XPath I can use double slash to express I want to get any node within document, no necessary a child ofa root node, e.g. //input would stand for any tag in my XML document. How do I express it with GPath expression?
dzieciou
  • 4,049
  • 8
  • 41
  • 85
2
votes
1 answer

Finding all XML nodes with REST assured's XmlPath

Let's say I have the following XML document:
Robert Strauch
  • 12,055
  • 24
  • 120
  • 192
2
votes
1 answer

Get value of an XML attribute with Groovy (gpath)

Using XmlParser() in groovy. See the following code. I need to print the value of answer when the value of name is type.
user2475310
  • 733
  • 4
  • 13
  • 19
2
votes
2 answers

Deleting nodes in XML using Xpath in Groovy

I've got this Groovy code working to delete nodes using xpath strings, but I'm having problems deleting nodes where the xpath results in multiple node instances. Sample XML... foo bar
raffian
  • 31,267
  • 26
  • 103
  • 174
2
votes
1 answer

Is there an XPath into Groovy GPath compiler?

We have quite a lot of legacy XPath expressions and are considering to migrate the code over to Groovy + XmlSlurper + GPath. I'm thinking the task would be smoother if there was a tool (or an API) that takes an existing XPath and produces/executes…
Vladimir Dyuzhev
  • 18,130
  • 10
  • 48
  • 62
1
vote
1 answer

How to use 'find' in restassured to search this nested array structure?

In restassured, it's possible to use JsonPath 'find' function to search for object. https://www.javadoc.io/doc/io.rest-assured/json-path/3.0.0/io/restassured/path/json/JsonPath.html An example given in the link: { "store": { "book": [ { …
user1559625
  • 2,583
  • 5
  • 37
  • 75
1
vote
2 answers

Getting the value from the response element using GPath and Rest Assured

I want to get the value of status from my response. So that i can assert it. I'm using rest assured with java & serenity BDD. Response { "locationType": "STORE", "locationId": "0003", "events": { …
Aishu
  • 1,310
  • 6
  • 28
  • 52
1
vote
1 answer

How to get relative path using Groovy Gpath in json?

I am using rest assured with Serenity BDD and using Groovy Gpath to navigate thru JSON. Now, I have a scenario like where I need to get the Cost values more than 2 with below JSON. is there any way to use a relative path to navigate using GPath with…
1
vote
0 answers

How to translate XPath into Restassured xmlPath equivalent?

Does anyone know how to make following Xpath expression someRoot.children3.someLeaf[not(children3)]/@_uri to work with io.restassured.path.xml.XmlPath#get? XmlPath is using GPath but im an not familiar with it at all. Quoting: "It follows the…
Antoniossss
  • 31,590
  • 6
  • 57
  • 99
1
vote
1 answer

Finding a partial String match in an XmlPath expression using grep

I'm using RestAssured to help me with some testing. Given the following XML:
Steerpike
  • 1,712
  • 6
  • 38
  • 71
1
vote
1 answer

Using XPath with GPathResult to find all nodes and add new attribute

Edited... My knowledge in Groovy is basic and I need to perform the following action which I have no idea how to do. let's say I have this XML:
Yossi Even
  • 45
  • 8
1
vote
1 answer

Using AND clause in a GPath groovy statement to get all xml nodes matching >1 criteria

I am a newcomer to Groovy / GPath and am using it with RestAssured. I need some help with syntax for a query. Given the following xml snippet:
Steerpike
  • 1,712
  • 6
  • 38
  • 71
1
vote
2 answers

Is there a better way to find ancestors in xml using Groovy Gpath?

Please see my below groovy code which is working as expected - but wondered if there is a better way to get ancestor info? My sample xml record: String record = ''' Italy
user292049
  • 1,138
  • 1
  • 14
  • 20