ElementNode

data class ElementNode(val name: String, val namespace: String = "", val lang: String = "", val attributes: AttributeMap = emptyMap(), val children: List<Node> = listOf()) : Node

Represents a node with children in the XML tree

Constructors

Link copied to clipboard
constructor(name: String, namespace: String = "", lang: String = "", attributes: AttributeMap = emptyMap(), children: List<Node> = listOf())

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val id: String?

Return the id attribute as specified in getAttr with fallback to XML namespace

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val text: String?

Text of the first child if it is a TextNode, or null otherwise

Functions

Link copied to clipboard
fun collect(name: String, namespace: String): List<ElementNode>

Recursively collect all descendent ElementNode with the given name and namespace into a list

Link copied to clipboard

Recursively collect and concatenate all descendent TextNode in depth-first order

Link copied to clipboard
fun get(name: String, namespace: String): List<ElementNode>

Return a list of ElementNode children with the given name and namespace

Link copied to clipboard

Return a list of all ElementNode children

Link copied to clipboard
fun getAttr(name: String): String?

Return the value of an attribute picked in the same namespace as this ElementNode, fallback to no namespace and at last to null.

Link copied to clipboard
fun getAttrNs(name: String, namespace: String): String?

Return the value of an attribute picked in a specific namespace or null if it does not exist

Link copied to clipboard
fun getFirst(name: String, namespace: String): ElementNode?

Return the first ElementNode child with the given name and namespace, or null if there is none