public interface PathElement extends Iterable<String>
Modifier and Type | Method and Description |
---|---|
<T> T |
get(String name)
Get a value from the current XML object.
|
Node |
getNode(String name)
Get a
Node whose name matches the supplied name
from the current XML object. |
List<Node> |
getNodes(String name)
Get a list of
Node 's whose name matches the supplied name
from the current XML object. |
<T> T |
getPath(String path)
Get a value from the current XML using Groovy's GPath expression syntax.
|
<T> T |
getPath(String path,
Class<T> explicitType)
Get a value from the current XML using Groovy's GPath expression syntax.
|
forEach, iterator, spliterator
<T> T get(String name)
This method returns the child whose name matches name
. If several
children matches the name then a List
of Node's
are returned.
If this object is a Node and you want to return an attribute value you need to prefix the name with an @. E.g. given
<category type="present"> <item when="Aug 10"> <name>Kathryn's Birthday</name> <price>200</price> </item> </category>then
String type = node.get("@type");will return "present".
T
- The expected type of the return value.name
- The name of the child, children or attribute.<T> T getPath(String path)
T
- The expected type of the return value.path
- The GPath expression syntax<T> T getPath(String path, Class<T> explicitType)
T
- The expected type of the return value.path
- The GPath expression syntaxexplicitType
- Converts the outcome of the GPath expression to tis type if allowedNode getNode(String name)
Node
whose name matches the supplied name
from the current XML object.
Note that there's no guarantee that this method actually
will return a Node. It could result in a .name
- The name of the Node to get.null
if non were found.Copyright © 2010–2016. All rights reserved.