Import std.data.xml
XmlNode
class
Public Class XmlNode Implements Printable
A node of an XML tree: an element, with a Name, Attributes, and Children; text, CDATA, or a comment, with its Content; a processing instruction, with its target as its Name and its Content; or an attribute, with its Name and value as its Content, as XmlPath selects one.
Examples
Local note = XmlNode("note")
note.SetAttribute("lang", "en")
note.AddElement("to").AddText("Ada")
Expect("{note}" == "<note lang=\"en\"><to>Ada</to></note>")
Expect(note.Element("to")?.Text == "Ada")-
Whether it's an element, text, CDATA, a comment, a processing instruction, or an attribute.
-
An element's or attribute's name, or a processing instruction's target.
-
The text of text, CDATA, a comment, or a processing instruction, or an attribute's value.
-
An element's attributes, by name, in order.
-
An element's children, in order.
-
A new element named
name. Panics whennameisn't an XML name. -
A node of
text. -
A CDATA section of
text. -
A comment of
text. -
@PanicsAtCaller Public Static Method NewInstruction(target: String, text: String): XmlNodestatic method #A processing instruction for
target. Panics whentargetisn't an XML name. -
Its text, as XPath's string() has it: an element's text and CDATA's, and its children's, in order; and another node's Content.
-
An element's attribute's value, or Null when it has none of that
name. -
Gives an element's attribute a value, adding it at the end when it's new. Panics when
nameisn't an XML name. -
An element's first child element named
name, or Null. -
An element's child elements, in order, or those named
namewhen it isn't "". -
Adds
childat the end of an element's children, and gives it. -
Adds a new element named
name, and gives it. Panics whennameisn't an XML name. -
Adds
textat the end of an element's children. -
The nodes
pathselects, from this one, in the document's order: XmlPath's subset of XPath 1.0. Panics whenpathisn't one XmlPath reads. -
The first node
pathselects, or Null when it selects none. Panics as Query does. -
As XML, on one line: an element as Xml.Write writes it without the declaration, text with its '&', '<', and '>' escaped, a CDATA section, a comment, a processing instruction, or an attribute as name="value". Panics as Xml.Write does, at a node that holds what XML can't.
Report an issue with this page or with FutureBlitz on GitHub.