Creates an empty XElement with the given name.
ReadonlynameThe qualified name of this element.
The kind of XML node this object represents.
The parent of this object in the XML tree, or null if it is a root.
Gets the first child node, or null if the container is empty.
Gets the last child node, or null if the container is empty.
Gets the first attribute of this element, or null if there are none.
Gets the last attribute of this element, or null if there are none.
Returns true if this element has at least one attribute.
Returns true if this element contains at least one child element.
Returns true if this element has no child nodes.
Gets the previous sibling node, or null if this is the first node.
Gets the next sibling node, or null if this is the last node.
Returns a shallow copy of this container's child nodes.
A new array containing all direct child XNode instances.
Inserts content immediately after an existing child node.
The reference child node.
Content to insert after the child.
Appends content as children of this container.
Nodes, strings, or arrays to add.
Content rules:
Replaces all child nodes with the specified content.
New content to use as children.
Removes all child nodes from this container.
Returns all descendant nodes of this container in document order.
A flat array of all descendant XNode instances.
Inserts content as the first children of this container.
Nodes, strings, or arrays to prepend.
Inserts content immediately before an existing child node.
The reference child node.
Content to insert before the child.
Replaces an existing child node with the specified content.
The child node to replace.
Content that replaces the child.
Removes a specific child node from this container.
The child node to remove.
Returns the attributes of this element filtered by name.
Name to filter by.
Returns the attribute with the specified name, or null.
The attribute name to look up.
The matching XAttribute, or null.
Returns this element followed by all its descendant nodes in document order.
An array starting with this element and including all descendant nodes.
Returns this element followed by all its descendant elements in document order.
An array starting with this element (if it matches) and including all matching descendant elements.
Removes a specific attribute from this element.
The attribute instance to remove.
Removes all attributes from this element.
Replaces all attributes on this element with the specified content.
New attributes (or arrays of attributes) to set.
Sets, updates, or removes an attribute by name.
The attribute name.
The new value, or null to remove.
Sets, updates, or removes a child element by name.
The child element name.
The new text value, or null to remove.
Removes all attributes and child nodes from this element.
Replaces all attributes and child nodes with the specified content.
New content (nodes, attributes, strings, or arrays).
Returns this element followed by all its ancestor elements.
An array starting with this element and continuing to the root.
Compares this element with another for structural equality, including name, attributes, and all child nodes.
The element to compare against.
true if the elements are structurally identical.
Serialises this element and its subtree to an XML string.
The XML string representation.
StaticparseStaticloadStaticloadInserts the specified content immediately after this node in its parent.
One or more nodes or strings to insert.
Returns all sibling nodes that precede this node.
An array of XNode instances before this node.
Returns all sibling nodes that follow this node.
An array of XNode instances after this node.
Performs a deep structural comparison of this node with another.
The node to compare against.
true if the two nodes are structurally identical.
StaticdeepStatic convenience method for deep structural comparison of two nodes.
First node.
Second node.
true if the two nodes are structurally identical.
Removes annotations from this object.
Represents an XML element -- the primary class in LtXmlTs.
Remarks
An
XElementhas a name, zero or more attributes, and zero or more child nodes. It supports functional construction (passing children and attributes to the constructor), parsing from strings or files, and serialisation to XML strings.Example