Class TNode
TNode represents a single node in the XML representation of a Test or TestResult. It replaces System.Xml.XmlNode and System.Xml.Linq.XElement, providing a minimal set of methods for operating on the XML in a platform-independent manner.
Inherited Members
Namespace: NUnit.Framework.Interfaces
Assembly: nunit.framework.dll
Syntax
public sealed class TNode
Constructors
View SourceTNode(string)
Constructs a new instance of TNode
Declaration
public TNode(string name)
Parameters
Type | Name | Description |
---|---|---|
string | name | The name of the node |
TNode(string, string?)
Constructs a new instance of TNode with a value
Declaration
public TNode(string name, string? value)
Parameters
Type | Name | Description |
---|---|---|
string | name | The name of the node |
string | value | The text content of the node |
TNode(string, string?, bool)
Constructs a new instance of TNode with a value
Declaration
public TNode(string name, string? value, bool valueIsCDATA)
Parameters
Type | Name | Description |
---|---|---|
string | name | The name of the node |
string | value | The text content of the node |
bool | valueIsCDATA | Flag indicating whether to use CDATA when writing the text |
Properties
View SourceAttributes
Gets the dictionary of attributes
Declaration
public TNode.AttributeDictionary Attributes { get; }
Property Value
Type | Description |
---|---|
TNode.AttributeDictionary |
ChildNodes
Gets a list of child nodes
Declaration
public TNode.NodeList ChildNodes { get; }
Property Value
Type | Description |
---|---|
TNode.NodeList |
FirstChild
Gets the first ChildNode
Declaration
public TNode? FirstChild { get; }
Property Value
Type | Description |
---|---|
TNode |
Name
Gets the name of the node
Declaration
public string Name { get; }
Property Value
Type | Description |
---|---|
string |
OuterXml
Gets the XML representation of this node.
Declaration
public string OuterXml { get; }
Property Value
Type | Description |
---|---|
string |
Value
Gets the value of the node
Declaration
public string? Value { get; set; }
Property Value
Type | Description |
---|---|
string |
ValueIsCDATA
Gets a flag indicating whether the value should be output using CDATA.
Declaration
public bool ValueIsCDATA { get; set; }
Property Value
Type | Description |
---|---|
bool |
Methods
View SourceAddAttribute(string, string)
Adds an attribute with a specified name and value to the XmlNode.
Declaration
public void AddAttribute(string name, string value)
Parameters
Type | Name | Description |
---|---|---|
string | name | The name of the attribute. |
string | value | The value of the attribute. |
AddChildNode(TNode)
Adds a child node to this node.
Declaration
public void AddChildNode(TNode node)
Parameters
Type | Name | Description |
---|---|---|
TNode | node | The child node to add. |
AddElement(string)
Adds a new element as a child of the current node and returns it.
Declaration
public TNode AddElement(string name)
Parameters
Type | Name | Description |
---|---|---|
string | name | The element name. |
Returns
Type | Description |
---|---|
TNode | The newly created child element |
AddElement(string, string)
Adds a new element with a value as a child of the current node and returns it.
Declaration
public TNode AddElement(string name, string value)
Parameters
Type | Name | Description |
---|---|---|
string | name | The element name |
string | value | The text content of the new element |
Returns
Type | Description |
---|---|
TNode | The newly created child element |
AddElementWithCDATA(string, string)
Adds a new element with a value as a child of the current node and returns it. The value will be output using a CDATA section.
Declaration
public TNode AddElementWithCDATA(string name, string value)
Parameters
Type | Name | Description |
---|---|---|
string | name | The element name |
string | value | The text content of the new element |
Returns
Type | Description |
---|---|
TNode | The newly created child element |
FromXml(string)
Create a TNode from its XML text representation
Declaration
public static TNode FromXml(string xmlText)
Parameters
Type | Name | Description |
---|---|---|
string | xmlText | The XML text to be parsed |
Returns
Type | Description |
---|---|
TNode | A TNode |
InsertChildNode(int, TNode)
Inserts a child nodeat the specified index.
Declaration
public void InsertChildNode(int index, TNode node)
Parameters
Type | Name | Description |
---|---|---|
int | index | The zero-based index at which |
TNode | node | The node to insert. |
SelectNodes(string)
Finds all descendants of this node matching an XPath specification. The format of the specification is limited to what is needed by NUnit and its tests.
Declaration
public List<TNode> SelectNodes(string xpath)
Parameters
Type | Name | Description |
---|---|---|
string | xpath |
Returns
Type | Description |
---|---|
List<TNode> |
SelectSingleNode(string)
Finds a single descendant of this node matching an XPath specification. The format of the specification is limited to what is needed by NUnit and its tests.
Declaration
public TNode? SelectSingleNode(string xpath)
Parameters
Type | Name | Description |
---|---|---|
string | xpath |
Returns
Type | Description |
---|---|
TNode |
WriteTo(XmlWriter)
Writes the XML representation of the node to an XmlWriter
Declaration
public void WriteTo(XmlWriter writer)
Parameters
Type | Name | Description |
---|---|---|
XmlWriter | writer |