X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fnetconf-util%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Futil%2Fxml%2FXmlElement.java;h=4e3a66b7ec5f7edfe0399bcab74e6a1843ed0449;hp=ac200a0aa668c1a406e044e11205ac90c20fc478;hb=a6a97a57081df63432dde5a6b1613eb779b74d79;hpb=f2b0b8646e5e8060dbb1a8278ddaf0f4b2a422c0 diff --git a/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/xml/XmlElement.java b/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/xml/XmlElement.java index ac200a0aa6..4e3a66b7ec 100644 --- a/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/xml/XmlElement.java +++ b/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/xml/XmlElement.java @@ -224,11 +224,17 @@ public final class XmlElement { }); } + /** + * + * @param tagName tag name without prefix + * @return + */ public List getChildElements(final String tagName) { return getChildElementsInternal(new ElementFilteringStrategy() { @Override public boolean accept(Element e) { - return e.getTagName().equals(tagName); + // localName returns pure localName without prefix + return e.getLocalName().equals(tagName); } }); } @@ -338,6 +344,17 @@ public final class XmlElement { ); } + public Optional getOnlyTextContentOptionally() { + // only return text content if this node has exactly one Text child node + if (element.getChildNodes().getLength() == 1) { + Node item = element.getChildNodes().item(0); + if (item instanceof Text) { + return Optional.of(((Text) item).getWholeText()); + } + } + return Optional.absent(); + } + public String getNamespaceAttribute() throws MissingNameSpaceException { String attribute = element.getAttribute(XmlUtil.XMLNS_ATTRIBUTE_KEY); if (attribute == null || attribute.equals("")){