Definition
Assembly: CloudNimble.XmlEssentials.dll Namespace: CloudNimble.Text.Xml.NodesSyntax
Summary
Represents the ordered list of child nodes of an XmlElementNode. This class cannot be inherited.Usage
XmlNodeList is the type of XmlElementNode.Children. It’s an IList<XmlNode> that holds an element’s child nodes in document order: elements, text, CDATA sections, comments, and processing instructions. Use it to count, index, insert at a position, remove, and replace.
XmlElementNode has one.
View the complete sample on GitHub
Remarks
A node can belong to one list at a time. Adding, inserting, or assigning a node that already has a parent throws an XmlException, andnull throws an
ArgumentNullException. A node that is removed or replaced has no parent afterward.
Considerations
- A node belongs to one list at a time.
Add,Insert, and the index setter throw anXmlException(“The node already has a parent.”) for a node that has a parent. Remove it first to move it, or add aDeepCloneto copy it. Remove,RemoveAt,Clear, and replacing through the index setter set theParentof the node that leaves the list tonull.Removereturnsfalsewhen the node isn’t in the list.- In a tree parsed from an indented document, the list holds a text node for each run of white space between elements. Don’t assume that an index holds an element.
- Don’t change the list while a
foreachloop enumerates it. After a change, the loop’s next step throws anInvalidOperationException(“Collection was modified; enumeration operation may not execute.”), as aList<T>or aJsonArraydoes. Loop over a copy (list.ToArray()), or loop by index from the end. - The list accepts the kinds of node that can be content: elements, text, CDATA sections, comments, and processing instructions. Adding an
XmlAttributeNodeor anXmlDeclarationNodethrows anXmlException. When an assignment to an index is refused, the node that was there stays.
Constructors
.ctor Inherited
Inherited from
objectSyntax
Properties
Count
Syntax
Property Value
Type:int
IsReadOnly
Syntax
Property Value
Type:bool
this[]
Syntax
Property Value
Type:CloudNimble.Text.Xml.Nodes.XmlNode
Methods
Add
Syntax
Parameters
Clear
Syntax
Contains
Syntax
Parameters
Returns
Type:bool
CopyTo
Syntax
Parameters
Equals Inherited Virtual
Inherited from
objectSyntax
Parameters
Returns
Type:bool
Equals Inherited
Inherited from
objectSyntax
Parameters
Returns
Type:bool
GetEnumerator
Returns an enumerator that iterates through the nodes in order.Syntax
Returns
Type:System.Collections.Generic.IEnumerator<CloudNimble.Text.Xml.Nodes.XmlNode>
An enumerator for the list.
Remarks
The list must not change while it is enumerated. After a node is added, inserted, removed, or replaced, or the list is cleared, the next call to MoveNext throws an InvalidOperationException. To change the list in a loop, enumerate a copy of it.GetHashCode Inherited Virtual
Inherited from
objectSyntax
Returns
Type:int
GetType Inherited
Inherited from
objectSyntax
Returns
Type:System.Type
IndexOf
Syntax
Parameters
Returns
Type:int
Insert
Syntax
Parameters
MemberwiseClone Inherited
Inherited from
objectSyntax
Returns
Type:object
ReferenceEquals Inherited
Inherited from
objectSyntax
Parameters
Returns
Type:bool
Remove
Syntax
Parameters
Returns
Type:bool
RemoveAt
Syntax
Parameters
ToString Inherited Virtual
Inherited from
objectSyntax
Returns
Type:string?
Related APIs
- CloudNimble.Text.Xml.Nodes.XmlElementNode
- CloudNimble.Text.Xml.Nodes.XmlNode
- CloudNimble.Text.Xml.Nodes.XmlAttributeNodeList