Questions tagged [xmlslurper]

XMLSlurper is a Groovy class that makes parsing and working with XML simpler than with Java.

You can read more here

241 questions
3
votes
1 answer

Groovy XMLSlurper appendNode - how force it to take effect?

I understand that XML document changes are not immediate when using Groovy's XMLSlurper and StreamingMarkupBuilder. However, I'm not happy having to do a lot of processing whenever I change a document. The only way I've gotten it to work is if I…
Mark
  • 1,988
  • 2
  • 24
  • 42
3
votes
1 answer

can I use XmlSlurper directly on a w3c.dom.Node object

I am experimenting with GroovyWS in the hope of completely replacing Axis2 client code. One of the Webservice operations I call returns fragments of XML, which I need to turn into Groovy Beans. I am getting instances of…
Ben Hammond
  • 705
  • 1
  • 7
  • 20
3
votes
0 answers

Jenkins node attribute access returns boolean instead of value

I'm trying to parse XML in Jenkins pipeline using XmlSlurper. ...
3
votes
1 answer

Reading XML element with XmlSlurper in Groovy

I'd like to parse an XML document (SOAP request message) for a particular element. The document is stored in requestContent and looks as follows:
Robert Strauch
  • 12,055
  • 24
  • 120
  • 192
3
votes
2 answers

Is it possible to parse sub-trees with Groovy XMLSlurper

Does anyone know whether it is possible to utilise XMLSlurper in a fashion that means individual sub-trees can be pulled from a very large XML document and processed individually? Imagine you've got a huge XML feed containing a root element that has…
DrewEaster
  • 3,316
  • 3
  • 35
  • 39
3
votes
1 answer

Change xml element/tag name using XmlSlurper or XmlParser

I have an xml that looks like this Sample1 01/20/2016 I want to simply change the…
user3714598
  • 1,733
  • 5
  • 28
  • 45
3
votes
1 answer

Sorting XML in Groovy

I have looked at the documentation on sorting XML with Groovy def records = new XmlParser().parseText(XmlExamples.CAR_RECORDS) assert ['Royale', 'P50', 'HSV Maloo'] == records.car.sort{ it.'@year'.toInteger() }.'@name' but what I am trying to do is…
Aaron Saunders
  • 33,180
  • 5
  • 60
  • 80
3
votes
0 answers

How do I extract XML tags similar to XPATH with the XmlSlurper API in Java?

I am able to traverse the XML tree by importing the XmlSlurper API, but how do I extract specific tags from the XML like with XPATH? I want to extract them using the XmlSlurper API in Java in a way similar to the question How to apply predicate to…
erj2code
  • 301
  • 5
  • 9
  • 19
3
votes
2 answers

Groovy delete a tag in a XMLSlurper, replaceNode {} does nothing

I am parsing some XML with XMLSlurper (groovy 1.7.4) and I need to delete a tag (not make it empty!). Here is a code sample illustrating it: import groovy.xml.StreamingMarkupBuilder def CAR_RECORDS = '''
Eric Darchis
  • 24,537
  • 4
  • 28
  • 49
3
votes
2 answers

XmlSlurper: Obtain the line number of groovy.util.slurpersupport.NodeChild in original file

I am using XmlSlurper to parse an XML file for processing. I need to find the line number, of some matching criteria, within the file. Here is what I have so far: def void findServlets() { this.servlets = webFile.depthFirst().findAll{ …
3
votes
2 answers

How to parse non-well formatted HTML with XmlSlurper

I'm trying to parse a non-well-formatted HTML page with XmlSlurper, the Eclipse download site The W3C validator shows several errors in the page. I tried the fault-tolerant parser from this post @Grab(group='net.sourceforge.nekohtml',…
allprog
  • 16,540
  • 9
  • 56
  • 97
3
votes
1 answer

collect attributes and values into string list

I have xml data looking like this: John Doe Jane Doe I want to collect them into a list of maps like [[key: M, name: John Doe], [key: N, name: Jane Doe]] and I use, after…
serafim
  • 75
  • 1
  • 1
  • 9
3
votes
1 answer

Parsing XML in Groovy with namespace and entities

Parsing XML in Groovy should be a piece of cake, but I always run into problems. I would like to parse a string like this:

This is a test with some formattings.
And this has a…

rdmueller
  • 10,742
  • 10
  • 69
  • 126
3
votes
1 answer

Nested GPath expressions with XmlSlurper and findAll

I'm trying to analyse an XML tree using XmlSlurper and GPath, and the behaviour of the findAll method confuses me. Say, for example, that you have the following XML tree:
  • Element…
Nicolas Rinaudo
  • 6,068
  • 28
  • 41
2
votes
1 answer

Groovy XMLSlurper namespace error without namespaces

I have following XML that XMLSlurper is unable to parse. I think XMLSlurper thinks the xxx:yyy is some kind of namespace. Is there any chance to change this behavior?
thelittlebug
  • 137
  • 1
  • 8
1 2
3
16 17