Interface XmlNode
-
- All Known Implementing Classes:
JcabiXmlNode
,NativeXmlNode
public interface XmlNode
XML document node. This abstraction is used to represent an XML node in the XML document. We added it to be able to use two different implementations of XML nodes: - one from the jcabi library - another native implementation- Since:
- 0.7
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description 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.XmlNode
firstChild()
Get first child.boolean
hasAttribute(String name, String value)
Check if an attribute exists.Optional<XmlNode>
optchild(String attribute, String value)
Get optional child node by attribute.String
text()
Retrieve node text content.void
validate()
Validate the node.List<String>
xpath(String xpath)
Find elements by xpath.
-
-
-
Method Detail
-
text
String text()
Retrieve node text content.- Returns:
- Text content.
-
attribute
Optional<String> attribute(String name)
Get attribute.- Parameters:
name
- Attribute name.- Returns:
- Attribute.
-
child
XmlNode child(String name)
Get child node.- Parameters:
name
- Child node name.- Returns:
- Child node.
-
xpath
List<String> xpath(String xpath)
Find elements by xpath.- Parameters:
xpath
- XPath.- Returns:
- List of elements.
-
child
XmlNode child(String attribute, String value)
Get child node by attribute.- Parameters:
attribute
- Attribute name.value
- Attribute value.- Returns:
- Child node.
-
optchild
Optional<XmlNode> optchild(String attribute, String value)
Get optional child node by attribute.- Parameters:
attribute
- Attribute name.value
- Attribute value.- Returns:
- Child node.
-
firstChild
XmlNode firstChild()
Get first child.- Returns:
- First child node.
-
hasAttribute
boolean hasAttribute(String name, String value)
Check if an attribute exists.- Parameters:
name
- Attribute name.value
- Attribute value.- Returns:
- True if an attribute with specified value exists.
-
validate
void validate()
Validate the node.
-
-