public class XmlExtensions
extends Object
This class defines all the new XML-related groovy methods which enhance the normal JDK XML classes when inside the Groovy environment. Static methods are used with the first parameter the destination class.
| Type Params | Return Type | Name and description |
|---|---|---|
<T> |
public static T |
asType(Node self, Class<T> type)Enables node as Type coercion for XML Nodes.
|
|
public boolean |
hasNext() |
|
public static Iterator<Node> |
iterator(NodeList nodeList)Makes NodeList iterable by returning a read-only Iterator which traverses over each Node. |
|
public Node |
next() |
|
public void |
remove() |
|
public static String |
serialize(Element element)Transforms the element to its text equivalent. |
Enables node as Type coercion for XML Nodes.
Converts the Node to a Map via Node.toMap and then
uses Groovy's standard Map coercion to produce the typed object.
Does not require Jackson on the classpath.
self - the Node to converttype - the target typeT - the target typeMakes NodeList iterable by returning a read-only Iterator which traverses over each Node.
nodeList - a NodeList Transforms the element to its text equivalent.
(The resulting string does not contain a xml declaration. Use XmlUtil.serialize(element) if you need the declaration.)
element - the element to serialize