parsers::xml
Functions
Parse xml into a Document (slab DOM).
Never throws.
The returned document always has at least the root node (root). Malformed input is tolerated: unterminated tags/comments/CDATA consume to end-of-input, and a </x> with no matching open element is ignored rather than aborting the parse.
xml | the document text. |
the parsed document (root-only for empty/blank input).
O(n) time in the length of xml.
the node slab and its strings on the heap (owned by the returned Document).
The document root's node id (its children are the top-level nodes).
O(1).
none.
doc | the document. |
the root node id (its children are the top-level nodes).
Whether id is a valid element node in doc.
O(1).
none.
doc | the document. |
id | the node id to test. |
true iff id is a valid element node.
The tag name of element id, or "" if id is not an element.
O(1).
one result string.
doc | the document. |
id | the element node id. |
the tag name, or "" if id is not an element.
Value of attribute name on element id, or "" if absent (or id is not an element).
O(k) in the attribute count of id.
one result string.
doc | the document. |
id | the element node id. |
name | the attribute name. |
the attribute value, or "" if absent.
ParsersXml.AttributeQuotingFormsWhether element id carries an attribute named name.
O(k) in the attribute count of id.
none.
doc | the document. |
id | the element node id. |
name | the attribute name. |
whether id carries attribute name.
The concatenated text of node id: for a text node, its own text; for an element, all descendant text in document order (like an XML .textContent).
O(m) in the number of descendants of id.
one result string.
doc | the document. |
id | the node id. |
the concatenated descendant text.
The child node ids of id, in document order (elements and text).
O(1) (returns a copy of the id list).
the id list.
doc | the document. |
id | the node id. |
the child node ids in document order.
ParsersXml.FindFindallIterChildrenThe id of the first child element of id whose tag equals tag, or -1 if none.
(Direct children only — not descendants; use iter for the whole subtree.)
O(c) in the direct-child count of id.
none.
doc | the document. |
id | the parent node id. |
tag | the child tag to match. |
the first matching child element id, or -1.
ParsersXml.FindFindallIterChildrenThe ids of all direct child elements of id whose tag equals tag, in order.
O(c) in the direct-child count of id.
the result id list.
doc | the document. |
id | the parent node id. |
tag | the child tag to match. |
the matching direct-child element ids.
ParsersXml.FindFindallIterChildrenThe ids of every element in the subtree rooted at id (including id itself) whose tag equals tag, in document order — the analogue of an XML tree .iter(tag).
O(m) in the subtree size of id.
the result id list (and a transient walk stack).
doc | the document. |
id | the subtree root node id. |
tag | the tag to match. |
the matching element ids in the subtree, in document order.
ParsersXml.FindFindallIterChildren