Class XmlNodeExtensions
A static class that contains extension methods for the System.Xml.XmlNode class.
Inheritance
Inherited Members
Namespace: Juhta.Net.Extensions
Assembly: Juhta.Net.dll
Syntax
public static class XmlNodeExtensions
Methods
| Improve this Doc View SourceAppendChild(XmlNode, String)
Appends a child node to the current node.
Declaration
public static XmlNode AppendChild(this XmlNode node, string childName)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Xml.XmlNode | node | Specifies the current node. |
| System.String | childName | Specifies a name for the child node. |
Returns
| Type | Description |
|---|---|
| System.Xml.XmlNode | Returns the appended child node. |
AppendChild(XmlNode, String, String)
Appends a child node to the current node.
Declaration
public static XmlNode AppendChild(this XmlNode node, string childName, string childInnerText)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Xml.XmlNode | node | Specifies the current node. |
| System.String | childName | Specifies a name for the child node. |
| System.String | childInnerText | Specifies an inner text for the child node. |
Returns
| Type | Description |
|---|---|
| System.Xml.XmlNode | Returns the appended child node. |
AppendChild(XmlNode, String, String, String)
Appends a child node to the current node.
Declaration
public static XmlNode AppendChild(this XmlNode node, string qualifiedChildName, string namespaceUri, string innerText)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Xml.XmlNode | node | Specifies the current node. |
| System.String | qualifiedChildName | Specifies a qualified name for the child node. |
| System.String | namespaceUri | Specifies a namespace URI for the child node. |
| System.String | innerText | Specifies an inner text for the child node. Can be null. |
Returns
| Type | Description |
|---|---|
| System.Xml.XmlNode | Returns the appended child node. |
AppendChild(XmlNode, String, String, String[], String[])
Appends a child node to the current node.
Declaration
public static XmlNode AppendChild(this XmlNode node, string childName, string childInnerText, string[] attributeNames, string[] attributeValues)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Xml.XmlNode | node | Specifies the current node. |
| System.String | childName | Specifies a name for the child node. |
| System.String | childInnerText | Specifies an inner text for the child node. Can be null. |
| System.String[] | attributeNames | A string array specifying names for the attributes to be added to the child node. Can be null. |
| System.String[] | attributeValues | A string array specifying values for the attributes to be added to the child
node. This parameter will be ignored if |
Returns
| Type | Description |
|---|---|
| System.Xml.XmlNode | Returns the appended child node. |
Remarks
The lengths of the arrays attributeNames and attributeValues
must match.
CopyTo(XmlNode, XmlNode)
Copies the current node to another node.
Declaration
public static void CopyTo(this XmlNode node, XmlNode destination)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Xml.XmlNode | node | Specifies the current node. |
| System.Xml.XmlNode | destination | Specifies a destination node. |
Remarks
Copying covers all attributes and child nodes.
GetAttribute(XmlNode, String)
Gets an attribute value from the current node.
Declaration
public static string GetAttribute(this XmlNode node, string name)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Xml.XmlNode | node | Specifies the current node. |
| System.String | name | Specifies an attribute name. |
Returns
| Type | Description |
|---|---|
| System.String | Returns the value of the specified attribute or an empty string, if the attribute wasn't found. |
GetAttribute(XmlNode, String, String)
Gets an attribute value from the current node.
Declaration
public static string GetAttribute(this XmlNode node, string name, string defaultValue)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Xml.XmlNode | node | Specifies the current node. |
| System.String | name | Specifies an attribute name. |
| System.String | defaultValue | Specifies a default value for the attribute. |
Returns
| Type | Description |
|---|---|
| System.String | Returns the value of the specified attribute or the default value, if the attribute wasn't found. |
HasAttribute(XmlNode, String)
Checks whether the current node has a specified attribute.
Declaration
public static bool HasAttribute(this XmlNode node, string name)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Xml.XmlNode | node | Specifies the current node. |
| System.String | name | Specifies an attribute name. |
Returns
| Type | Description |
|---|---|
| System.Boolean | Returns true if the current node has the specified attribute, otherwise false. |
SetAttribute(XmlNode, String, String)
Sets an attribute to the current node.
Declaration
public static void SetAttribute(this XmlNode node, string name, string value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Xml.XmlNode | node | Specifies the current node. |
| System.String | name | Specifies a name for the attribute to be set. |
| System.String | value | Specifies a value for the attribute to be set. |
Remarks
If the attribute already exists the function just updates its value.