Class XmlNode


  • public final class XmlNode
    extends Object
    XML smart element. Utility class that simplifies work with XML.
    Since:
    0.1
    • Constructor Detail

      • XmlNode

        public XmlNode​(String xml)
        Constructor.
        Parameters:
        xml - XML string.
      • XmlNode

        public XmlNode​(Node parent)
        Constructor.
        Parameters:
        parent - Parent node.
    • Method Detail

      • node

        public Node node()
        To XML node.
        Returns:
        Xml node
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • child

        public XmlNode child​(String name)
        Get child node.
        Parameters:
        name - Child node name.
        Returns:
        Child node.
      • optchild

        public Optional<XmlNode> optchild​(String name)
        Get optional child node.
        Parameters:
        name - Child node name.
        Returns:
        Child node.
      • child

        public XmlNode child​(String attribute,
                             String value)
        Get child node by attribute.
        Parameters:
        attribute - Attribute name.
        value - Attribute value.
        Returns:
        Child node.
      • optchild

        public Optional<XmlNode> optchild​(String attribute,
                                          String value)
        Get optional child node by attribute.
        Parameters:
        attribute - Attribute name.
        value - Attribute value.
        Returns:
        Child node.
      • firstChild

        public XmlNode firstChild()
        Get first child.
        Returns:
        First child node.
      • children

        public Stream<XmlNode> children()
        Get all child nodes.
        Returns:
        Child nodes.
      • text

        public String text()
        Retrieve node text content.
        Returns:
        Text content.
      • attribute

        public Optional<String> attribute​(String name)
        Get attribute.
        Parameters:
        name - Attribute name.
        Returns:
        Attribute.
      • hasAttribute

        public boolean hasAttribute​(String name,
                                    String value)
        Check if attribute exists.
        Parameters:
        name - Attribute name.
        value - Attribute value.
        Returns:
        True if attribute with specified value exists.
      • append

        public void append​(XmlNode entry)
        Append entry to the end of the node.
        Parameters:
        entry - Entry.
      • erase

        public void erase()
        Remove this node from parent.