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
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
append(XmlNode entry)
Append entry to the end of the node.Optional<String>
attribute(String name)
Get attribute.XmlNode
child(String name)
Get child node.XmlNode
child(String attribute, String value)
Get child node by attribute.Stream<XmlNode>
children()
Get all child nodes.boolean
equals(Object obj)
void
erase()
Remove this node from parent.XmlNode
firstChild()
Get first child.boolean
hasAttribute(String name, String value)
Check if attribute exists.int
hashCode()
Node
node()
To XML node.Optional<XmlNode>
optchild(String name)
Get optional child node.Optional<XmlNode>
optchild(String attribute, String value)
Get optional child node by attribute.String
text()
Retrieve node text content.String
toString()
-
-
-
Method Detail
-
node
public Node node()
To XML node.- Returns:
- Xml node
-
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.
-
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.
-
-