Class NativeXmlNode

java.lang.Object
org.eolang.jeo.representation.xmir.NativeXmlNode
All Implemented Interfaces:
XmlNode

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

    • NativeXmlNode

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

      public NativeXmlNode(Node parent)
      Constructor.
      Parameters:
      parent - Xml node.
  • Method Details

    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

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

      public String toString()
      Overrides:
      toString in class Object
    • children

      public Stream<XmlNode> children()
      Description copied from interface: XmlNode
      Get all child nodes.
      Specified by:
      children in interface XmlNode
      Returns:
      Child nodes.
    • text

      public String text()
      Description copied from interface: XmlNode
      Retrieve node text content.
      Specified by:
      text in interface XmlNode
      Returns:
      Text content.
    • attribute

      public Optional<String> attribute(String name)
      Description copied from interface: XmlNode
      Get attribute.
      Specified by:
      attribute in interface XmlNode
      Parameters:
      name - Attribute name.
      Returns:
      Attribute.
    • child

      public XmlNode child(String name)
      Description copied from interface: XmlNode
      Get child node.
      Specified by:
      child in interface XmlNode
      Parameters:
      name - Child node name.
      Returns:
      Child node.
    • xpath

      public List<String> xpath(String xpath)
      Find elements by xpath.
      Specified by:
      xpath in interface XmlNode
      Parameters:
      xpath - XPath.
      Returns:
      List of elements.
    • child

      public XmlNode child(String attribute, String value)
      Description copied from interface: XmlNode
      Get child node by attribute.
      Specified by:
      child in interface XmlNode
      Parameters:
      attribute - Attribute name.
      value - Attribute value.
      Returns:
      Child node.
    • optchild

      public Optional<XmlNode> optchild(String attribute, String value)
      Description copied from interface: XmlNode
      Get optional child node by attribute.
      Specified by:
      optchild in interface XmlNode
      Parameters:
      attribute - Attribute name.
      value - Attribute value.
      Returns:
      Child node.
    • firstChild

      public XmlNode firstChild()
      Description copied from interface: XmlNode
      Get first child.
      Specified by:
      firstChild in interface XmlNode
      Returns:
      First child node.
    • hasAttribute

      public boolean hasAttribute(String name, String value)
      Description copied from interface: XmlNode
      Check if an attribute exists.
      Specified by:
      hasAttribute in interface XmlNode
      Parameters:
      name - Attribute name.
      value - Attribute value.
      Returns:
      True if an attribute with specified value exists.
    • validate

      public void validate()
      Description copied from interface: XmlNode
      Validate the node.
      Specified by:
      validate in interface XmlNode