aboutsummaryrefslogtreecommitdiffstats
path: root/vespajlib/src/main/java/com/yahoo/text/XML.java
diff options
context:
space:
mode:
Diffstat (limited to 'vespajlib/src/main/java/com/yahoo/text/XML.java')
-rw-r--r--vespajlib/src/main/java/com/yahoo/text/XML.java7
1 files changed, 7 insertions, 0 deletions
diff --git a/vespajlib/src/main/java/com/yahoo/text/XML.java b/vespajlib/src/main/java/com/yahoo/text/XML.java
index 255e6a67429..c2b8a0b2289 100644
--- a/vespajlib/src/main/java/com/yahoo/text/XML.java
+++ b/vespajlib/src/main/java/com/yahoo/text/XML.java
@@ -333,6 +333,13 @@ public class XML {
return (getChildren(e, name).size() >= 1) ? getChildren(e, name).get(0) : null;
}
+ /** @return the value of child with the given name, empty string if no value, or empty if no child with name */
+ public static Optional<String> getChildValue(Element e, String name) {
+ var child = getChild(e, name);
+ if (child == null) return Optional.empty();
+ return Optional.of(getValue(child));
+ }
+
/**
* Returns the path to the given xml node, where each node name is separated by the given separator string.
*