Class XmlNode

java.lang.Object
org.eolang.jeo.representation.xmir.XmlNode

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

    • XmlNode

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

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

    • node

      public Node node()
      To XML node.
      Returns:
      Xml node
    • 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
    • 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.