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
1
vote
1 answer

How to get html tag text using XMLSlurper in Groovy

I am trying to modify html code in Groovy. I parsed it using XMLSlurper. The problem is i need to edit text of certain tag which contains text and children tags. Html code looks like this:
  • Text to modifymore text
In…
Bazyl
  • 68
  • 1
  • 5
1
vote
1 answer

Groovy shows java.io.NotSerializableException when making prepared statement

When executing the following piece of code: def xml = new XmlSlurper().parse(url) title = rss.chanel.title rss.channel.item.each { sql.firstRow("SELECT COUNT(*) FROM news WHERE title = ? ", [it.title]) } I get the following error: Invalid…
user1418225
1
vote
1 answer

parsing XML gives me a list of slurpersupport attributes but I want a list of texts

I fetch an xml file from the internet using a URL def url = "http://www.kth.se/api/kopps/v1/course/DD1390/round/2014:2/1".toURL() InputStream inp = url.openStream() def kursomgXML = new…
serafim
  • 75
  • 1
  • 1
  • 9
1
vote
3 answers

How navigate back in XML tree to get to an adjacent child element using parent method

Given the following XML: ... USD/KRW 1024.400024
Saba Ahang
  • 578
  • 9
  • 24
1
vote
3 answers

Groovy - XmlSlurper - find innermost element

I have the following xml: 100 200 300 400 Given an xml, how can we get the innermost elements (in this case, all…
saravana_pc
  • 2,607
  • 11
  • 42
  • 66
1
vote
1 answer

How to read the coloned attribute names (Eg. model:name) while parsing xml using XmlSlurper

I have an XMl where an attribute is e.g. model:name. After upgrading to Grails 2, it fails to extract the attribute using it.@"model:name".text() I have read How to read the hyphenated attribute names (Eg. model_name) while parsing xml using…
mamruoc
  • 847
  • 3
  • 11
  • 21
1
vote
3 answers

Parse XML using Groovy and XmlSlurper and iterate the tags

I am able to parse XML through HTTP URL by using Groovy and XmlSlurper and output the values associated to tags. Below is the generated sample XML page. 10100 TST-3
Naren
  • 109
  • 1
  • 3
  • 13
1
vote
0 answers

How to read the xml Declaration with groovy xmlSlurper

I'm currently having trouble with reading some xml files that have different encodings. Therefore I'm trying to get the encoding out of the xml Declaration. I know that to create the Declaration you use root.mkp.xmlDeclaration(version:"1.0",…
Fanvaron
  • 155
  • 2
  • 10
1
vote
1 answer

Groovy XmlSlurper replaceNode doesn't work with a found node

I'm having issues using replaceNode programmatically when a simple example works fine. Building on a previous Question, this code works but swap out the line marked SWAP and it breaks. Can anyone show me how to make this work with a node returned…
1
vote
2 answers

XML Parsing with same element tags but unique data

I am parsing xml that has many of the same tag. Inside the tag there is a name of a value and then the value. My issue is is that I need to separate those values. This is an example of the xml I have to parse 10.0.0.0. …
CoffeePeddlerIntern
  • 659
  • 3
  • 13
  • 29
1
vote
1 answer

XmlSlurper Append node with namespace

I am trying to append node to my request using xmlslurper Service.appendNode{ ifx:DepAcctId{ if (acctId!=""){ifx:AcctId("123")} } } This results in 123 I want it to append the namespace,…
1
vote
3 answers

Properly iterating through XML with namespaces in Groovy

I have the following xml code:
maschwenk
  • 569
  • 1
  • 9
  • 20
1
vote
2 answers

Finding xml element value case insensitive using XmlSlurper/GPath?

I am parsing a piece of XML using XmlSlurper and need to find an xml elements value. The challenge in this is that i am not always sure if the casing in the xml document will be correct, so i need to find the element in any possible…
Marco
  • 15,101
  • 33
  • 107
  • 174
0
votes
2 answers

Parse UTF-8 xml file with XmlSlurper

I'm trying to parse google atom with XmlSlurper. My use case is something like this. 1) Send an atom xml to server with rest client. 2)Handle request and parse it on server side. I develop my server with Groovy and used XmlSlurper as a parser. But i…
erimerturk
  • 4,230
  • 25
  • 25
0
votes
1 answer

How to use XMLSlurper and setKeepIgnorableWhiteSpace()

I have a piece of Grails code which is downloading an XML file, parsing it, making some changes, then writing it back again. def xmlFile = simpleSftpService.downloadFile('theFile.xml') def rootNode = new…
Simon
  • 97
  • 3
  • 13