Table of Contents

Class TNode

Namespace
NUnit.Framework.Interfaces
Assembly
nunit.framework.dll

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.

public sealed class TNode
Inheritance
TNode
Inherited Members

Constructors

TNode(string)

Constructs a new instance of TNode

public TNode(string name)

Parameters

name string

The name of the node

TNode(string, string?)

Constructs a new instance of TNode with a value

public TNode(string name, string? value)

Parameters

name string

The name of the node

value string

The text content of the node

TNode(string, string?, bool)

Constructs a new instance of TNode with a value

public TNode(string name, string? value, bool valueIsCDATA)

Parameters

name string

The name of the node

value string

The text content of the node

valueIsCDATA bool

Flag indicating whether to use CDATA when writing the text

Properties

Attributes

Gets the dictionary of attributes

public TNode.AttributeDictionary Attributes { get; }

Property Value

TNode.AttributeDictionary

ChildNodes

Gets a list of child nodes

public TNode.NodeList ChildNodes { get; }

Property Value

TNode.NodeList

FirstChild

Gets the first ChildNode

public TNode? FirstChild { get; }

Property Value

TNode

Name

Gets the name of the node

public string Name { get; }

Property Value

string

OuterXml

Gets the XML representation of this node.

public string OuterXml { get; }

Property Value

string

Value

Gets the value of the node

public string? Value { get; set; }

Property Value

string

ValueIsCDATA

Gets a flag indicating whether the value should be output using CDATA.

public bool ValueIsCDATA { get; set; }

Property Value

bool

Methods

AddAttribute(string, string)

Adds an attribute with a specified name and value to the XmlNode.

public void AddAttribute(string name, string value)

Parameters

name string

The name of the attribute.

value string

The value of the attribute.

AddChildNode(TNode)

Adds a child node to this node.

public void AddChildNode(TNode node)

Parameters

node TNode

The child node to add.

AddElement(string)

Adds a new element as a child of the current node and returns it.

public TNode AddElement(string name)

Parameters

name string

The element name.

Returns

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.

public TNode AddElement(string name, string value)

Parameters

name string

The element name

value string

The text content of the new element

Returns

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.

public TNode AddElementWithCDATA(string name, string value)

Parameters

name string

The element name

value string

The text content of the new element

Returns

TNode

The newly created child element

FromXml(string)

Create a TNode from its XML text representation

public static TNode FromXml(string xmlText)

Parameters

xmlText string

The XML text to be parsed

Returns

TNode

A TNode

InsertChildNode(int, TNode)

Inserts a child nodeat the specified index.

public void InsertChildNode(int index, TNode node)

Parameters

index int

The zero-based index at which node should be inserted.

node TNode

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.

public List<TNode> SelectNodes(string xpath)

Parameters

xpath string

Returns

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.

public TNode? SelectSingleNode(string xpath)

Parameters

xpath string

Returns

TNode

WriteTo(XmlWriter)

Writes the XML representation of the node to an XmlWriter

public void WriteTo(XmlWriter writer)

Parameters

writer XmlWriter