groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mauro Molinari (JIRA)" <>
Subject [jira] [Commented] (GROOVY-1832) XMLParser: remove method on NodeList returns true (success). But, Node is not removed.
Date Wed, 28 Feb 2018 15:17:00 GMT


Mauro Molinari commented on GROOVY-1832:

Hi Paul,
I find the current Groovy behaviour crazy... I'm using {{XmlParser}} because I need to parse
and manipulate an XML file, then save it elsewhere, so the page at []
suggests it's better to use {{XmlParser}} rather than {{XmlSluper}} (which would require a
reparsing after each change - at least this is what I understand).

I'm traversing the tree by iterating over children of a given node, so I am iterating over
NodeLists a lot. Neither of these seem to work to actually delete nodes from he XML tree:
 * Iterator.remove
 * Collection.removeAll(Closure)
 * nodeToRemove.parent().remove(nodeToRemove) (once nodeToRemove has been found by iteration
over the NodeList)

No errors, simply nothing is done, the XML tree still has the node.

Now I'm trying the "findAll" way, but I really think this is broken.

By the way, the page at []
is supposed to show examples for modifying/removing nodes, but no remove example is shown.

> XMLParser: remove method on NodeList returns true (success).  But, Node is not removed.
> ---------------------------------------------------------------------------------------
>                 Key: GROOVY-1832
>                 URL:
>             Project: Groovy
>          Issue Type: Improvement
>          Components: XML Processing
>    Affects Versions: 1.0
>         Environment: Windows XP.    Eclipse 3.2.
>            Reporter: Ricky Gomez
>            Assignee: Paul King
>            Priority: Minor
>             Fix For: 1.1-rc-1
>         Attachments: XmlParserRemoveTest.groovy
> Using XMLParser:
> node.nodelist.remove(o)  returns true.   But node is not removed.
> I think the node.nodelist.remove(o) syntax is preferred to o.parent().value.remove(o)
which does work.

This message was sent by Atlassian JIRA

View raw message