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
2
votes
1 answer

Groovy Xml Parsing with namespaces

I've been trying to do some xml modifications with groovy's XML Slurper. Basically, i'm going through the xml and looking for tags or attributes that have ? as the value and then replacing it with some value. I've got it working for xml that…
eric
  • 21
  • 1
  • 2
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
2 answers

Groovy XmlSlurper get value of the node without children

I'm parsing HTML and trying to value of a parent node itself, without values of the children nodes. HTML example:
extra stuff Text I would like to get. …
MeIr
  • 7,236
  • 6
  • 47
  • 80
2
votes
1 answer

Groovy XmlSlurper get value out of NodeChildren

I'm parsing HTML and trying to get full / not parsed value out of one particular node. HTML example:
Hello
World
!
MeIr
  • 7,236
  • 6
  • 47
  • 80
2
votes
1 answer

Groovy XmlSlurper with TagSoup and non-breaking space values

I'm parsing some HTML4 with Groovy's XmlSlurper backed by a tagsoup Parser. I'm getting the text() of a node successfully, but HTML   spaces are giving me some difficulty when trying to test for equality with another value. Specifically,…
Scott Heaberlin
  • 3,364
  • 1
  • 23
  • 22
2
votes
3 answers

Groovy XmlSlurper parse mixed text and nodes

I'm currently trying to parse a node in groovy which contains mixed text and nodes with text and I need to get the text in the right order for example:

The text has …

Fanvaron
  • 155
  • 2
  • 10
2
votes
0 answers

Groovy XML: How to parse, modify and serialize the content of a GSP file. (org.xml.sax.SAXParseException, prefix not bound)

Before I ask this question I will provide some info on what I am actually trying to do: I need to refactor a large amount of GSP files in my grails project. After I tried writing my own groovy script for that -- and realizing that it is way too…
nst1nctz
  • 333
  • 3
  • 23
2
votes
1 answer

Rendering XML response on Grails problem

I'm having problems rendering an XML file parsed via XMLSlurper to an XML variable. Below is my code. def userFile =new File("test.xml") def xml= new XmlSlurper().parse(userFile) render xml The problem is I cannot see the xml being rendered into my…
Anthony Umpad
  • 165
  • 3
  • 11
2
votes
2 answers

groovy XmlSlurper not parse my xml file

I have an xml, and I can't parse this file with xmlslurper. Here a copy of my xml file : The protein encoded by this gene is a plasma glycoprotein of unknown function. The protein shows sequence…
Fabien Barbier
  • 1,514
  • 4
  • 28
  • 41
2
votes
1 answer

xmlslurper not coying namespace declarations

I am having this XML,
2
votes
1 answer

Can generic XML by parsed as nicely as simple XML in Groovy?

Given a nice, simple XML structure, XmlSlurper() can allow me to read values from it very easily. def xml = "groovy" def html = new XmlSlurper().parseText(xml) println html.head.title Is there a way to…
John Flinchbaugh
  • 2,338
  • 1
  • 17
  • 20
2
votes
2 answers

How to set user agent in: new XmlSlurper().parse(URL)

I am launching requests to a web service using Groovy/XmlSlurper: new XmlSlurper().parse("http://en.wikipedia.org/w/api.php?action=...") I would like to set the user agent to let the website know what project the requests are from. How to set the…
Nicolas Raoul
  • 58,567
  • 58
  • 222
  • 373
1
vote
1 answer

Groovy: XmlSlurper, Failed to replace the node first and try to append the same node again. any one faced this issue

//Unable to add replaced nodes back to xml using xml slurper. Throws stackoverflow exception. Now idea how to do it def xml = """
siva
  • 11
  • 2
1
vote
1 answer

How keep groovy/XMLSlurper from stripping html tags from a node?

I'm reading an HTML file from a POST response and parsing it with XMLSlurper. The textarea node on the page has some HTML code put into it (non-urlencoded - not my choice) and when I read that value, Groovy strips all the tags. Example: …
Don Rhummy
  • 24,730
  • 42
  • 175
  • 330
1
vote
2 answers

How would I find the text of a node that has a specific value for an attribute in groovy?

I'm using XMLSlurper. My code is below (but does not work). The problem is that it fails when it hits a node that does not have the attribute "id". How do I account for this? //Parse XML def page = new XmlSlurper(false,false).parseText(xml) //Now…
Don Rhummy
  • 24,730
  • 42
  • 175
  • 330