Class

# XMLAttribute

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Description

Represents an XML attribute node.

## Properties

<div class="rst-class">

table-centered_columns_3_and_4

</div>

| Name                                            | Type                                     | Read-Only | Shared |
|-------------------------------------------------|------------------------------------------|-----------|--------|
| `AttributeCount<xmlattribute.attributecount>`   | `Integer</api/data_types/integer>`       | ✓         |        |
| `ChildCount<xmlattribute.childcount>`           | `Integer</api/data_types/integer>`       | ✓         |        |
| `FirstChild<xmlattribute.firstchild>`           | `XMLNode</api/text/xml/xmlnode>`         | ✓         |        |
| `LastChild<xmlattribute.lastchild>`             | `XMLNode</api/text/xml/xmlnode>`         | ✓         |        |
| `LastError<xmlattribute.lasterror>`             | `Integer</api/data_types/integer>`       | ✓         |        |
| `LocalName<xmlattribute.localname>`             | `String</api/data_types/string>`         | ✓         |        |
| `Name<xmlattribute.name>`                       | `String</api/data_types/string>`         |           |        |
| `NamespaceURI<xmlattribute.namespaceuri>`       | `String</api/data_types/string>`         | ✓         |        |
| `NextSibling<xmlattribute.nextsibling>`         | `XMLNode</api/text/xml/xmlnode>`         | ✓         |        |
| `OwnerDocument<xmlattribute.ownerdocument>`     | `XMLDocument</api/text/xml/xmldocument>` | ✓         |        |
| `OwnerElement<xmlattribute.ownerelement>`       | `XMLElement</api/text/xml/xmlelement>`   |           |        |
| `Parent<xmlattribute.parent>`                   | `XMLNode</api/text/xml/xmlnode>`         | ✓         |        |
| `Prefix<xmlattribute.prefix>`                   | `String</api/data_types/string>`         | ✓         |        |
| `PreviousSibling<xmlattribute.previoussibling>` | `XMLNode</api/text/xml/xmlnode>`         | ✓         |        |
| `ToString<xmlattribute.tostring>`               | `String</api/data_types/string>`         | ✓         |        |
| `Type<xmlattribute.type>`                       | `Integer</api/data_types/integer>`       | ✓         |        |
| `Value<xmlattribute.value>`                     | `String</api/data_types/string>`         |           |        |

## Methods

<div class="rst-class">

table-centered_column_4

</div>

<table>
<thead>
<tr class="header">
<th>Name</th>
<th>Parameters</th>
<th>Returns</th>
<th>Shared</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td><code class="interpreted-text" role="ref">AppendChild&lt;xmlattribute.appendchild&gt;</code></td>
<td>newChild As <code class="interpreted-text" role="doc">XMLNode&lt;/api/text/xml/xmlnode&gt;</code></td>
<td><code class="interpreted-text" role="doc">XMLNode&lt;/api/text/xml/xmlnode&gt;</code></td>
<td></td>
</tr>
<tr class="even">
<td><code class="interpreted-text" role="ref">Child&lt;xmlattribute.child&gt;</code></td>
<td>index As <code class="interpreted-text" role="doc">Integer&lt;/api/data_types/integer&gt;</code></td>
<td><code class="interpreted-text" role="doc">XMLNode&lt;/api/text/xml/xmlnode&gt;</code></td>
<td></td>
</tr>
<tr class="odd">
<td><code class="interpreted-text" role="ref">Clone&lt;xmlattribute.clone&gt;</code></td>
<td>deep As <code class="interpreted-text" role="doc">Boolean&lt;/api/data_types/boolean&gt;</code></td>
<td><code class="interpreted-text" role="doc">XMLNode&lt;/api/text/xml/xmlnode&gt;</code></td>
<td></td>
</tr>
<tr class="even">
<td><code class="interpreted-text" role="ref">Compare&lt;xmlattribute.compare&gt;</code></td>
<td>node As <code class="interpreted-text" role="doc">XMLNode&lt;/api/text/xml/xmlnode&gt;</code></td>
<td><code class="interpreted-text" role="doc">Integer&lt;/api/data_types/integer&gt;</code></td>
<td></td>
</tr>
<tr class="odd">
<td><code class="interpreted-text" role="ref">GetAttribute&lt;xmlattribute.getattribute&gt;</code></td>
<td>name As <code class="interpreted-text" role="doc">String&lt;/api/data_types/string&gt;</code></td>
<td><code class="interpreted-text" role="doc">String&lt;/api/data_types/string&gt;</code></td>
<td></td>
</tr>
<tr class="even">
<td></td>
<td>uri As <code class="interpreted-text" role="doc">String&lt;/api/data_types/string&gt;</code>, name As <code class="interpreted-text" role="doc">String&lt;/api/data_types/string&gt;</code></td>
<td><code class="interpreted-text" role="doc">String&lt;/api/data_types/string&gt;</code></td>
<td></td>
</tr>
<tr class="odd">
<td><code class="interpreted-text" role="ref">GetAttributeNode&lt;xmlattribute.getattributenode&gt;</code></td>
<td>index As <code class="interpreted-text" role="doc">Integer&lt;/api/data_types/integer&gt;</code></td>
<td>XMLAttribute</td>
<td></td>
</tr>
<tr class="even">
<td></td>
<td>name As <code class="interpreted-text" role="doc">String&lt;/api/data_types/string&gt;</code></td>
<td>XMLAttribute</td>
<td></td>
</tr>
<tr class="odd">
<td></td>
<td>uri As <code class="interpreted-text" role="doc">String&lt;/api/data_types/string&gt;</code>, name As <code class="interpreted-text" role="doc">String&lt;/api/data_types/string&gt;</code></td>
<td>XMLAttribute</td>
<td></td>
</tr>
<tr class="even">
<td><code class="interpreted-text" role="ref">Insert&lt;xmlattribute.insert&gt;</code></td>
<td>newChild As <code class="interpreted-text" role="doc">XMLNode&lt;/api/text/xml/xmlnode&gt;</code>, beforeChild As <code class="interpreted-text" role="doc">XMLNode&lt;/api/text/xml/xmlnode&gt;</code></td>
<td><code class="interpreted-text" role="doc">XMLNode&lt;/api/text/xml/xmlnode&gt;</code></td>
<td></td>
</tr>
<tr class="odd">
<td><code class="interpreted-text" role="ref">RemoveAttribute&lt;xmlattribute.removeattribute&gt;</code></td>
<td>name As <code class="interpreted-text" role="doc">String&lt;/api/data_types/string&gt;</code></td>
<td></td>
<td></td>
</tr>
<tr class="even">
<td><code class="interpreted-text" role="ref">RemoveAttributeNode&lt;xmlattribute.removeattributenode&gt;</code></td>
<td>attributeNode As XMLAttribute</td>
<td>XMLAttribute</td>
<td></td>
</tr>
<tr class="odd">
<td><code class="interpreted-text" role="ref">RemoveChild&lt;xmlattribute.removechild&gt;</code></td>
<td>oldChild As <code class="interpreted-text" role="doc">XMLNode&lt;/api/text/xml/xmlnode&gt;</code></td>
<td></td>
<td></td>
</tr>
<tr class="even">
<td><code class="interpreted-text" role="ref">ReplaceChild&lt;xmlattribute.replacechild&gt;</code></td>
<td>newChild As <code class="interpreted-text" role="doc">XMLNode&lt;/api/text/xml/xmlnode&gt;</code>, oldChild As <code class="interpreted-text" role="doc">XMLNode&lt;/api/text/xml/xmlnode&gt;</code></td>
<td><code class="interpreted-text" role="doc">XMLNode&lt;/api/text/xml/xmlnode&gt;</code></td>
<td></td>
</tr>
<tr class="odd">
<td><code class="interpreted-text" role="ref">SetAttribute&lt;xmlattribute.setattribute&gt;</code></td>
<td>name As <code class="interpreted-text" role="doc">String&lt;/api/data_types/string&gt;</code>, value As <code class="interpreted-text" role="doc">String&lt;/api/data_types/string&gt;</code></td>
<td></td>
<td></td>
</tr>
<tr class="even">
<td></td>
<td>uri As <code class="interpreted-text" role="doc">String&lt;/api/data_types/string&gt;</code>, name As <code class="interpreted-text" role="doc">String&lt;/api/data_types/string&gt;</code>, value As <code class="interpreted-text" role="doc">String&lt;/api/data_types/string&gt;</code></td>
<td></td>
<td></td>
</tr>
<tr class="odd">
<td><code class="interpreted-text" role="ref">SetAttributeNode&lt;xmlattribute.setattributenode&gt;</code></td>
<td>attributeNode As XMLAttribute</td>
<td>XMLAttribute</td>
<td></td>
</tr>
<tr class="even">
<td></td>
<td>attributeNode As <code class="interpreted-text" role="doc">XMLAttribute&lt;/api/text/xml/xmlattribute&gt;</code></td>
<td></td>
<td></td>
</tr>
<tr class="odd">
<td><code class="interpreted-text" role="ref">XQL&lt;xmlattribute.xql&gt;</code></td>
<td>query As <code class="interpreted-text" role="doc">String&lt;/api/data_types/string&gt;</code></td>
<td><code class="interpreted-text" role="doc">XMLNodeList&lt;/api/text/xml/xmlnodelist&gt;</code></td>
<td></td>
</tr>
<tr class="even">
<td><blockquote>
<p>""</p>
</blockquote></td>
<td>query As <code class="interpreted-text" role="doc">String&lt;/api/data_types/string&gt;</code>, map() As <code class="interpreted-text" role="doc">String&lt;/api/data_types/string&gt;</code></td>
<td><code class="interpreted-text" role="doc">XMLNodeList&lt;/api/text/xml/xmlnodelist&gt;</code></td>
<td></td>
</tr>
</tbody>
</table>

## Property descriptions

<div id="xmlattribute.attributecount">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

XMLAttribute.AttributeCount

**AttributeCount** As `Integer</api/data_types/integer>`

> The number of attributes this element contains.
>
> This property is read-only.

<div id="xmlattribute.childcount">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

XMLAttribute.ChildCount

**ChildCount** As `Integer</api/data_types/integer>`

> The number of child nodes contained by this node.
>
> This property is read-only.
>
> The example code below uses this XML. Assign it to a constant called `kXML`:
>
> ``` XML
> <?xml version="1.0" encoding="UTF-8"?>
> <League>
>     <Team name="Seagulls">
>         <Player name="Bob" position="1B" />
>         <Player name="Tom" position="2B" />
>     </Team>
>     <Team name="Pigeons">
>         <Player name="Bill" position="1B" />
>         <Player name="Tim" position="2B" />
>     </Team>
>     <Team name="Crows">
>         <Player name="Ben" position="1B" />
>         <Player name="Ty" position="2B" />
>     </Team>
> </League>
> ```
>
> This example displays the number of teams in the above XML:
>
> ``` Xojo
> Var xml As New XmlDocument(kXml)
> MessageBox("Teams in League: " + xml.DocumentElement.ChildCount.ToString)
> ```

<div id="xmlattribute.firstchild">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

XMLAttribute.FirstChild

**FirstChild** As `XMLNode</api/text/xml/xmlnode>`

> The first child of this node.
>
> This property is read-only.
>
> The example code below uses this XML. Assign it to a constant called `kXML`:
>
> ``` XML
> <?xml version="1.0" encoding="UTF-8"?>
> <League>
>     <Team name="Seagulls">
>         <Player name="Bob" position="1B" />
>         <Player name="Tom" position="2B" />
>     </Team>
>     <Team name="Pigeons">
>         <Player name="Bill" position="1B" />
>         <Player name="Tim" position="2B" />
>     </Team>
>     <Team name="Crows">
>         <Player name="Ben" position="1B" />
>         <Player name="Ty" position="2B" />
>     </Team>
> </League>
> ```
>
> This example displays the first Team in the League XML:
>
> ``` Xojo
> Var xml As New XmlDocument(kXML)
>
> MessageBox("First Team in League: " + xml.DocumentElement.FirstChild.GetAttribute("name"))
> ```

<div id="xmlattribute.lastchild">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

XMLAttribute.LastChild

**LastChild** As `XMLNode</api/text/xml/xmlnode>`

> The first child of this node.
>
> This property is read-only.
>
> The example code below uses this XML. Assign it to a constant called `kXML`:
>
> ``` XML
> <?xml version="1.0" encoding="UTF-8"?>
> <League>
>     <Team name="Seagulls">
>         <Player name="Bob" position="1B" />
>         <Player name="Tom" position="2B" />
>     </Team>
>     <Team name="Pigeons">
>         <Player name="Bill" position="1B" />
>         <Player name="Tim" position="2B" />
>     </Team>
>     <Team name="Crows">
>         <Player name="Ben" position="1B" />
>         <Player name="Ty" position="2B" />
>     </Team>
> </League>
> ```
>
> This example displays the last team in the League XML:
>
> ``` Xojo
> Var xml As New XmlDocument(kXML)
>
> MessageBox("Last Team in League: " + xml.DocumentElement.LastChild.GetAttribute("name"))
> ```

<div id="xmlattribute.lasterror">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

XMLAttribute.LastError

**LastError** As `Integer</api/data_types/integer>`

> Contains an error code after an `XMLException</api/exceptions/xmlexception>` occurs.
>
> This property is read-only.
>
> XMLNodeList.Item will specify an error code if the item could not be created, and XMLNodeList.ToString could as well.
>
> | Error Code | Description             |
> |------------|-------------------------|
> | 0          | No error occurred.      |
> | 1          | Index size error        |
> | 2          | DOM String size error   |
> | 3          | Hierarchy request error |
> | 4          | Wrong document          |
> | 5          | Invalid character       |
> | 6          | No data allowed         |
> | 7          | No modification allowed |
> | 8          | Not found               |
> | 9          | Not supported           |
> | 10         | In use attribute        |
> | 11         | Invalid state           |
> | 12         | Syntax error            |
> | 13         | Invalid modification    |
> | 14         | Namespace error         |
> | 15         | Invalid access          |
> | 16         | Invalid node type       |
> | 17         | Query parse error       |
> | 18         | Query execution error   |
> | 19         | Not OK                  |

<div id="xmlattribute.localname">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

XMLAttribute.LocalName

**LocalName** As `String</api/data_types/string>`

> The name of the node without the prefix.
>
> This property is read-only.
>
> The example code below uses this XML. Assign it to a constant called `kXML`:
>
> ``` XML
> <?xml version="1.0" encoding="UTF-8"?>
> <League>
>     <Team name="Seagulls">
>         <Player name="Bob" position="1B" />
>         <Player name="Tom" position="2B" />
>     </Team>
>     <Team name="Pigeons">
>         <Player name="Bill" position="1B" />
>         <Player name="Tim" position="2B" />
>     </Team>
>     <Team name="Crows">
>         <Player name="Ben" position="1B" />
>         <Player name="Ty" position="2B" />
>     </Team>
> </League>
> ```
>
> This example displays the name of the root node in the XML:
>
> ``` Xojo
> Var xml As New XmlDocument(kXML)
>
> MessageBox("LocalName of root node: " + xml.DocumentElement.LocalName) ' League
> ```

<div id="xmlattribute.name">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

XMLAttribute.Name

**Name** As `String</api/data_types/string>`

> The name of this node.
>
> The example code below uses this XML. Assign it to a constant called `kXML`:
>
> ``` XML
> <?xml version="1.0" encoding="UTF-8"?>
> <League>
>     <Team name="Seagulls">
>         <Player name="Bob" position="1B" />
>         <Player name="Tom" position="2B" />
>     </Team>
>     <Team name="Pigeons">
>         <Player name="Bill" position="1B" />
>         <Player name="Tim" position="2B" />
>     </Team>
>     <Team name="Crows">
>         <Player name="Ben" position="1B" />
>         <Player name="Ty" position="2B" />
>     </Team>
> </League>
> ```
>
> This example displays the name of the root node in the XML:
>
> ``` Xojo
> Var xml As New XmlDocument(kXML)
>
> MessageBox("Name of root node: " + xml.DocumentElement.Name) ' League
> ```
>
> This code changes the name of the root node from "League" to "AmericanLeague":
>
> ``` Xojo
> Var xml As New XmlDocument(kXML)
> xml.DocumentElement.Name = "AmericanLeague"
>
> MessageBox("Name of root node: " + xml.DocumentElement.Name) ' AmericanLeague
> ```

<div id="xmlattribute.namespaceuri">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

XMLAttribute.NamespaceURI

**NamespaceURI** As `String</api/data_types/string>`

> The namespaceURI of this node.
>
> This property is read-only.

<div id="xmlattribute.nextsibling">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

XMLAttribute.NextSibling

**NextSibling** As `XMLNode</api/text/xml/xmlnode>`

> The next node.
>
> This property is read-only.
>
> The example code below uses this XML. Assign it to a constant called `kXML`:
>
> ``` XML
> <?xml version="1.0" encoding="UTF-8"?>
> <League>
>     <Team name="Seagulls">
>         <Player name="Bob" position="1B" />
>         <Player name="Tom" position="2B" />
>     </Team>
>     <Team name="Pigeons">
>         <Player name="Bill" position="1B" />
>         <Player name="Tim" position="2B" />
>     </Team>
>     <Team name="Crows">
>         <Player name="Ben" position="1B" />
>         <Player name="Ty" position="2B" />
>     </Team>
> </League>
> ```
>
> This example shows how to walk over the team nodes in the above XML and displays each team name:
>
> ``` Xojo
> Var xml As New XmlDocument(kXML)
> Var n As XmlNode = xml.DocumentElement.FirstChild
>
> While n <> Nil
> MessageBox(n.Name + ": " + n.GetAttribute("name"))
> n = n.NextSibling
> Wend
> ```

<div id="xmlattribute.ownerdocument">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

XMLAttribute.OwnerDocument

**OwnerDocument** As `XMLDocument</api/text/xml/xmldocument>`

> The XMLDocument that contains this node.
>
> This property is read-only.
>
> Use this property to get a reference to the XMLDocument that you can then use with the various "Create" methods to add new items to the XML. This is useful when you have access to an XMLNode, but no longer have a reference to the XMLDocument that contains it.

<div id="xmlattribute.ownerelement">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

XMLAttribute.OwnerElement

**OwnerElement** As `XMLElement</api/text/xml/xmlelement>`

> A reference to the `XMLElement</api/text/xml/xmlelement>` that this attribute is part of.

<div id="xmlattribute.parent">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

XMLAttribute.Parent

**Parent** As `XMLNode</api/text/xml/xmlnode>`

> The parent of this node.
>
> This property is read-only.
>
> The example code below uses this XML. Assign it to a constant called `kXML`:
>
> ``` XML
> <?xml version="1.0" encoding="UTF-8"?>
> <League>
>     <Team name="Seagulls">
>         <Player name="Bob" position="1B" />
>         <Player name="Tom" position="2B" />
>     </Team>
>     <Team name="Pigeons">
>         <Player name="Bill" position="1B" />
>         <Player name="Tim" position="2B" />
>     </Team>
>     <Team name="Crows">
>         <Player name="Ben" position="1B" />
>         <Player name="Ty" position="2B" />
>     </Team>
> </League>
> ```
>
> This example displays the parent of the last team in the above XML:
>
> ``` Xojo
> Var xml As New XmlDocument(kXML)
> Var n As XmlNode = xml.DocumentElement.LastChild
>
> If n <> Nil Then
> MessageBox("Name of " + n.Name + " node: " + n.Parent.Name)
> End If
> ```

<div id="xmlattribute.prefix">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

XMLAttribute.Prefix

**Prefix** As `String</api/data_types/string>`

> The namespace prefix of this node.
>
> This property is read-only.

<div id="xmlattribute.previoussibling">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

XMLAttribute.PreviousSibling

**PreviousSibling** As `XMLNode</api/text/xml/xmlnode>`

> The preceding node.
>
> This property is read-only.
>
> The example code below uses this XML. Assign it to a constant called `kXML`:
>
> ``` XML
> <?xml version="1.0" encoding="UTF-8"?>
> <League>
>     <Team name="Seagulls">
>         <Player name="Bob" position="1B" />
>         <Player name="Tom" position="2B" />
>     </Team>
>     <Team name="Pigeons">
>         <Player name="Bill" position="1B" />
>         <Player name="Tim" position="2B" />
>     </Team>
>     <Team name="Crows">
>         <Player name="Ben" position="1B" />
>         <Player name="Ty" position="2B" />
>     </Team>
> </League>
> ```
>
> This example shows how to walk in reverse over the team nodes in the above XML and displays each team name:
>
> ``` Xojo
> Var xml As New XmlDocument(kXML)
> Var n As XmlNode = xml.DocumentElement.LastChild
>
> While n <> Nil
> MessageBox(n.Name + ": " + n.GetAttribute("name"))
> n = n.PreviousSibling
> Wend
> ```

<div id="xmlattribute.tostring">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

XMLAttribute.ToString

**ToString** As `String</api/data_types/string>`

> A string representation of this node.
>
> This property is read-only.
>
> The example code below uses this XML. Assign it to a constant called `kXML`:
>
> ``` XML
> <?xml version="1.0" encoding="UTF-8"?>
> <League>
>     <Team name="Seagulls">
>         <Player name="Bob" position="1B" />
>         <Player name="Tom" position="2B" />
>     </Team>
>     <Team name="Pigeons">
>         <Player name="Bill" position="1B" />
>         <Player name="Tim" position="2B" />
>     </Team>
>     <Team name="Crows">
>         <Player name="Ben" position="1B" />
>         <Player name="Ty" position="2B" />
>     </Team>
> </League>
> ```
>
> Display the XML for the first team node:
>
> ``` Xojo
> Var xml As New XmlDocument(kXML)
>
> Var n As XmlNode = xml.DocumentElement.FirstChild
>
> If n <> Nil Then
>     MessageBox("XML: " + n.ToString)
> End If
> ```

<div id="xmlattribute.type">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

XMLAttribute.Type

**Type** As `Integer</api/data_types/integer>`

> `Integer</api/data_types/integer>` constant denoting the type, such as Element, Attribute, TextNode, and so forth.
>
> Use the Class Constants of the `XMLNodeType</api/text/xml/xmlnodetype>` module to compare values.
>
> This property is read-only.

<div id="xmlattribute.value">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

XMLAttribute.Value

**Value** As `String</api/data_types/string>`

> Used in some nodes to set or get the value, such as `XMLTextNode</api/text/xml/xmltextnode>` and <span class="title-ref">XMLAttribute</span>.
>
> <div class="note">
>
> <div class="title">
>
> Note
>
> </div>
>
> Not supported by all XMLNode subclasses.
>
> </div>

## Method descriptions

<div id="xmlattribute.appendchild">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

XMLAttribute.AppendChild

**AppendChild**(newChild As `XMLNode</api/text/xml/xmlnode>`) As `XMLNode</api/text/xml/xmlnode>`

> Adds a child after the last child.
>
> Typically you will want to use the first syntax that returns an instance of the newly created child so that you can then attach information to the child.
>
> The following XML:
>
> ``` XML
> <?xml version="1.0" encoding="UTF-8"?>
> <League>
>     <Team name="Seagulls">
>         <Player name="Bob" position="1B" />
>         <Player name="Tom" position="2B" />
>     </Team>
>     <Team name="Pigeons">
>         <Player name="Bill" position="1B" />
>         <Player name="Tim" position="2B" />
>     </Team>
>     <Team name="Crows">
>         <Player name="Ben" position="1B" />
>         <Player name="Ty" position="2B" />
>     </Team>
> </League>
> ```
>
> Can be created using this code, which displays the XML to a TextArea and prompts you to save it to a file:
>
> ``` Xojo
> Var xml As New XmlDocument
>
> Var root As XmlNode
> root = xml.AppendChild(xml.CreateElement("League"))
>
> Var teamNode As XmlNode
> Var playerNode As XmlNode
>
> ' Create 1st team and its players
> teamNode = root.AppendChild(xml.CreateElement("Team"))
> teamNode.SetAttribute("name", "Seagulls")
>
> playerNode = teamNode.AppendChild(xml.CreateElement("Player"))
> playerNode.SetAttribute("name", "Bob")
> playerNode.SetAttribute("position", "1B")
>
> playerNode = teamNode.AppendChild(xml.CreateElement("Player"))
> playerNode.SetAttribute("name", "Tom")
> playerNode.SetAttribute("position", "2B")
>
> ' Create 2nd team and its players
> teamNode = root.AppendChild(xml.CreateElement("Team"))
> teamNode.SetAttribute("name", "Pigeons")
>
> playerNode = teamNode.AppendChild(xml.CreateElement("Player"))
> playerNode.SetAttribute("name", "Bill")
> playerNode.SetAttribute("position", "1B")
>
> playerNode = teamNode.AppendChild(xml.CreateElement("Player"))
> playerNode.SetAttribute("name", "Tim")
> playerNode.SetAttribute("position", "2B")
>
> ' Create 3rd team and its players
> teamNode = root.AppendChild(xml.CreateElement("Team"))
> teamNode.SetAttribute("name", "Crows")
>
> playerNode = teamNode.AppendChild(xml.CreateElement("Player"))
> playerNode.SetAttribute("name", "Ben")
> playerNode.SetAttribute("position", "1B")
>
> playerNode = teamNode.AppendChild(xml.CreateElement("Player"))
> playerNode.SetAttribute("name", "Ty")
> playerNode.SetAttribute("position", "2B")
>
> TextArea1.Text = xml.ToString
>
> DisplayXML(xml)
> ```

<div id="xmlattribute.child">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

XMLAttribute.Child

**Child**(index As `Integer</api/data_types/integer>`) As `XMLNode</api/text/xml/xmlnode>`

> Returns the child XMLNode at the position denoted by *index*. *index* is zero-based.
>
> This example loads the following XML, contained in a constant called `kTestXml`, into a new XMLDocument and then displays the team names:
>
> ``` XML
> <?xml version="1.0" encoding="UTF-8"?>
> <League>
>     <Team name="Seagulls">
>         <Player name="Bob" position="1B" />
>         <Player name="Tom" position="2B" />
>     </Team>
>     <Team name="Pigeons">
>         <Player name="Bill" position="1B" />
>         <Player name="Tim" position="2B" />
>     </Team>
>     <Team name="Crows">
>         <Player name="Ben" position="1B" />
>         <Player name="Ty" position="2B" />
>     </Team>
> </League>
> ```
>
> ``` Xojo
> ' Load XML
> Var xml As New XmlDocument
> Try
>     xml.LoadXml(kTestXml)
> Catch e As XmlException
>     MessageBox("XML error: " + e.Message)
>     Return
> End Try
>
> For team As Integer = 0 To xml.DocumentElement.ChildCount-1
>     MessageBox("Team: " + xml.DocumentElement.Child(team).GetAttribute("name"))
> Next
> ```

<div id="xmlattribute.clone">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

XMLAttribute.Clone

**Clone**(deep As `Boolean</api/data_types/boolean>`) As `XMLNode</api/text/xml/xmlnode>`

> Duplicates the current node. The *deep* parameter indicates whether to also duplicate all the child nodes. It returns an XMLNode.
>
> The example code below uses this XML. Assign it to a constant called `kXML`:
>
> ``` XML
> <?xml version="1.0" encoding="UTF-8"?>
> <League>
>     <Team name="Seagulls">
>         <Player name="Bob" position="1B" />
>         <Player name="Tom" position="2B" />
>     </Team>
>     <Team name="Pigeons">
>         <Player name="Bill" position="1B" />
>         <Player name="Tim" position="2B" />
>     </Team>
>     <Team name="Crows">
>         <Player name="Ben" position="1B" />
>         <Player name="Ty" position="2B" />
>     </Team>
> </League>
> ```
>
> Duplicate the first team node, change the team name and add it to the XML:
>
> ``` Xojo
> Var xml As New XmlDocument(kXML)
>
> Var n As XmlNode = xml.DocumentElement.FirstChild
>
> If n <> Nil Then
>     ' Duplicate the first team
>     Var dup As XmlNode = n.Clone(True)
>
>     ' Change its name to "Eagles"
>     dup.SetAttribute("name", "Eagles")
>
>     ' Add it to the XmlDocument
>     n.Parent.AppendChild(dup)
>
>     TextArea1.Text = xml.ToString
> End If
> ```
>
> The result would then be:
>
> ``` XML
> <?xml version="1.0" encoding="UTF-8"?>
> <League>
>     <Team name="Eagles">
>         <Player name="Bob" position="1B" />
>         <Player name="Tom" position="2B" />
>     </Team>
>     <Team name="Seagulls">
>         <Player name="Bob" position="1B" />
>         <Player name="Tom" position="2B" />
>     </Team>
>     <Team name="Pigeons">
>         <Player name="Bill" position="1B" />
>         <Player name="Tim" position="2B" />
>     </Team>
>     <Team name="Crows">
>         <Player name="Ben" position="1B" />
>         <Player name="Ty" position="2B" />
>     </Team>
> </League>
> ```

<div id="xmlattribute.compare">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

XMLAttribute.Compare

**Compare**(node As `XMLNode</api/text/xml/xmlnode>`) As `Integer</api/data_types/integer>`

> Compares two nodes, which must both have the same parent. Returns an Integer that works like `String.Compare<string.compare>`.
>
> The two nodes are compared using their string contents.
>
> - If XMLNode \< NodeToCompare it returns -1
> - If XMLNode = NodeToCompare it returns 0
> - If XMLNode \> NodeToCompare it returns 1
>
> If you need to compare nodes with different parents, use the `String.Compare<string.compare>` function on the `XMLNode.ToString<xmlnode.tostring>` value.

<div id="xmlattribute.getattribute">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

XMLAttribute.GetAttribute

**GetAttribute**(name As `String</api/data_types/string>`) As `String</api/data_types/string>`

**GetAttribute**(uri As `String</api/data_types/string>`, name As `String</api/data_types/string>`) As `String</api/data_types/string>`

> Gets the value of the attribute specified by *uri* and *name*.
>
> Returns "" (empty string) if the attribute does not exist.
>
> The following XML is stored in a constant called `kXML`:
>
> ``` XML
> <?xml version="1.0" encoding="UTF-8"?>
> <League>
>     <Team name="Seagulls">
>         <Player name="Bob" position="1B" />
>         <Player name="Tom" position="2B" />
>     </Team>
>     <Team name="Pigeons">
>         <Player name="Bill" position="1B" />
>         <Player name="Tim" position="2B" />
>     </Team>
>     <Team name="Crows">
>         <Player name="Ben" position="1B" />
>         <Player name="Ty" position="2B" />
>     </Team>
> </League>
> ```
>
> This example shows how to walk over the team nodes in the above XML and displays each team name:
>
> ``` Xojo
> Var xml As New XmlDocument(kXML)
> Var n As XmlNode = xml.DocumentElement.FirstChild
>
> While n <> Nil
> MessageBox(n.Name + ": " + n.GetAttribute("name"))
> n = n.NextSibling
> Wend
> ```

<div id="xmlattribute.getattributenode">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

XMLAttribute.GetAttributeNode

**GetAttributeNode**(index As `Integer</api/data_types/integer>`) As XMLAttribute

**GetAttributeNode**(name As `String</api/data_types/string>`) As XMLAttribute

**GetAttributeNode**(uri As `String</api/data_types/string>`, name As `String</api/data_types/string>`) As XMLAttribute

> Gets an XML attribute node of the attribute specified by *index* position. *index* is zero-based.
>
> > The following XML is stored in a constant called `kXML`:
> >
> > ``` XML
> > <?xml version="1.0" encoding="UTF-8"?>
> > <League>
> >     <Team name="Seagulls">
> >         <Player name="Bob" position="1B" />
> >         <Player name="Tom" position="2B" />
> >     </Team>
> >     <Team name="Pigeons">
> >         <Player name="Bill" position="1B" />
> >         <Player name="Tim" position="2B" />
> >     </Team>
> >     <Team name="Crows">
> >         <Player name="Ben" position="1B" />
> >         <Player name="Ty" position="2B" />
> >     </Team>
> > </League>
> > ```
> >
> > This example shows how to walk over the team nodes in the above XML and displays each team name:
> >
> > ``` Xojo
> > Var xml As New XmlDocument(kXML)
> > Var n As XmlNode = xml.DocumentElement.FirstChild
> >
> > Var an As XmlAttribute
> > While n <> Nil
> > an = n.GetAttributeNode("name")
> > MessageBox(n.Name + ": " + an.Value)
> >
> > n = n.NextSibling
> > Wend
> > ```

<div id="xmlattribute.insert">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

XMLAttribute.Insert

**Insert**(newChild As `XMLNode</api/text/xml/xmlnode>`, beforeChild As `XMLNode</api/text/xml/xmlnode>`) As `XMLNode</api/text/xml/xmlnode>`

> Inserts *newChild* before the position of *beforeChild*. It optionally returns a reference to the inserted node as an XMLNode.
>
> The children being added must be children of the node/document to which they are being inserted. The example demonstrates this.
>
> The following XML is stored in a constant called `kXML`:
>
> ``` XML
> <?xml version="1.0" encoding="UTF-8"?>
> <League>
>     <Team name="Seagulls">
>         <Player name="Bob" position="1B" />
>         <Player name="Tom" position="2B" />
>     </Team>
>     <Team name="Pigeons">
>         <Player name="Bill" position="1B" />
>         <Player name="Tim" position="2B" />
>     </Team>
>     <Team name="Crows">
>         <Player name="Ben" position="1B" />
>         <Player name="Ty" position="2B" />
>     </Team>
> </League>
> ```
>
> To add a new team before the first team in the XML:
>
> ``` Xojo
> Var xml As New XmlDocument(kXml)
>
> Var n1 As XmlNode = xml.DocumentElement.FirstChild
>
> ' Insert a new team before the first team currently
> ' in the XML
> Var newTeam As XmlNode
> newTeam = xml.DocumentElement.AppendChild(xml.CreateElement("Team"))
> newTeam.SetAttribute("name", "Eagles")
>
> xml.DocumentElement.Insert(newTeam, n1)
>
> TextArea1.Text = xml.ToString
> ```
>
> The result would then be:
>
> ``` XML
> <?xml version="1.0" encoding="UTF-8"?>
> <League>
>     <Team name="Eagles"/>
>     <Team name="Seagulls">
>         <Player name="Bob" position="1B" />
>         <Player name="Tom" position="2B" />
>     </Team>
>     <Team name="Pigeons">
>         <Player name="Bill" position="1B" />
>         <Player name="Tim" position="2B" />
>     </Team>
>     <Team name="Crows">
>         <Player name="Ben" position="1B" />
>         <Player name="Ty" position="2B" />
>     </Team>
> </League>
> ```

<div id="xmlattribute.removeattribute">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

XMLAttribute.RemoveAttribute

**RemoveAttribute**(name As `String</api/data_types/string>`)

> Removes the *name* attribute.

<div id="xmlattribute.removeattributenode">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

XMLAttribute.RemoveAttributeNode

**RemoveAttributeNode**(attributeNode As XMLAttribute) As XMLAttribute

> The following XML is stored in a constant called `kXML`:
>
> ``` XML
> <?xml version="1.0" encoding="UTF-8"?>
> <League>
>     <Team name="Seagulls">
>         <Player name="Bob" position="1B" />
>         <Player name="Tom" position="2B" />
>     </Team>
>     <Team name="Pigeons">
>         <Player name="Bill" position="1B" />
>         <Player name="Tim" position="2B" />
>     </Team>
>     <Team name="Crows">
>         <Player name="Ben" position="1B" />
>         <Player name="Ty" position="2B" />
>     </Team>
> </League>
> ```
>
> Remove the name attribute from the first Team:
>
> ``` Xojo
> Var xml As New XmlDocument(kXML)
> Var n As XmlNode = xml.DocumentElement.FirstChild
> Var an As XmlAttribute
> an = n.GetAttributeNode("name")
> n.RemoveAttributeNode(an)
>
> TextArea1.Text = xml.ToString
> ```
>
> The result would then be:
>
> ``` XML
> <?xml version="1.0" encoding="UTF-8"?>
> <League>
>     <Team>
>         <Player name="Bob" position="1B" />
>         <Player name="Tom" position="2B" />
>     </Team>
>     <Team name="Pigeons">
>         <Player name="Bill" position="1B" />
>         <Player name="Tim" position="2B" />
>     </Team>
>     <Team name="Crows">
>         <Player name="Ben" position="1B" />
>         <Player name="Ty" position="2B" />
>     </Team>
> </League>
> ```

<div id="xmlattribute.removechild">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

XMLAttribute.RemoveChild

**RemoveChild**(oldChild As `XMLNode</api/text/xml/xmlnode>`)

> Removes *oldChild* from the XML.
>
> The following XML is stored in a constant called `kXML`:
>
> ``` XML
> <?xml version="1.0" encoding="UTF-8"?>
> <League>
>     <Team name="Seagulls">
>         <Player name="Bob" position="1B" />
>         <Player name="Tom" position="2B" />
>     </Team>
>     <Team name="Pigeons">
>         <Player name="Bill" position="1B" />
>         <Player name="Tim" position="2B" />
>     </Team>
>     <Team name="Crows">
>         <Player name="Ben" position="1B" />
>         <Player name="Ty" position="2B" />
>     </Team>
> </League>
> ```
>
> Remove the "Seagulls" team from the XML:
>
> ``` Xojo
> Var xml As New XmlDocument(kXML)
>
> Var n As XmlNode = xml.DocumentElement.FirstChild
> Call xml.DocumentElement.RemoveChild(n)
>
> TextArea1.Text = xml.ToString
> ```
>
> The result would then be:
>
> ``` XML
> <?xml version="1.0" encoding="UTF-8"?>
> <League>
>     <Team name="Pigeons">
>         <Player name="Bill" position="1B" />
>         <Player name="Tim" position="2B" />
>     </Team>
>     <Team name="Crows">
>         <Player name="Ben" position="1B" />
>         <Player name="Ty" position="2B" />
>     </Team>
> </League>
> ```

<div id="xmlattribute.replacechild">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

XMLAttribute.ReplaceChild

**ReplaceChild**(newChild As `XMLNode</api/text/xml/xmlnode>`, oldChild As `XMLNode</api/text/xml/xmlnode>`) As `XMLNode</api/text/xml/xmlnode>`

> Replaces *oldChild* with *newChild*.
>
> ReplaceChild optionally returns a reference to the new child as an XMLNode.
>
> The following XML is stored in a constant called `kXML`:
>
> ``` XML
> <?xml version="1.0" encoding="UTF-8"?>
> <League>
>     <Team name="Seagulls">
>         <Player name="Bob" position="1B" />
>         <Player name="Tom" position="2B" />
>     </Team>
>     <Team name="Pigeons">
>         <Player name="Bill" position="1B" />
>         <Player name="Tim" position="2B" />
>     </Team>
>     <Team name="Crows">
>         <Player name="Ben" position="1B" />
>         <Player name="Ty" position="2B" />
>     </Team>
> </League>
> ```
>
> Replaces the "Seagulls" with a new team "Eagles":
>
> ``` Xojo
> Var xml As New XmlDocument(kXML)
>
> Var n As XmlNode = xml.DocumentElement.FirstChild
>
> Var teamNode As XmlNode
> Var playerNode As XmlNode
>
> ' Create a new team
> teamNode = xml.DocumentElement.AppendChild(xml.CreateElement("Team"))
> teamNode.SetAttribute("name", "Eagles")
>
> playerNode = teamNode.AppendChild(xml.CreateElement("Player"))
> playerNode.SetAttribute("name", "Fred")
> playerNode.SetAttribute("position", "1B")
>
> playerNode = teamNode.AppendChild(xml.CreateElement("Player"))
> playerNode.SetAttribute("name", "Phil")
> playerNode.SetAttribute("position", "2B")
>
> ' Replace the "Seagulls" with the "Eagles"
> xml.DocumentElement.ReplaceChild(teamNode, n)
>
> TextArea1.Text = xml.ToString
> ```
>
> The result would then be:
>
> ``` XML
> <?xml version="1.0" encoding="UTF-8"?>
> <League>
>     <Team name="Eagles">
>     <Player name="Fred" position="1B"/>
>     <Player name="Phil" position="2B"/>
>     </Team>
>     <Team name="Pigeons">
>     <Player name="Bill" position="1B"/>
>     <Player name="Tim" position="2B"/>
>     </Team>
>     <Team name="Crows">
>     <Player name="Ben" position="1B"/>
>     <Player name="Ty" position="2B"/>
>     </Team>
> </League>
> ```

<div id="xmlattribute.setattribute">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

XMLAttribute.SetAttribute

**SetAttribute**(name As `String</api/data_types/string>`, value As `String</api/data_types/string>`)

**SetAttribute**(uri As `String</api/data_types/string>`, name As `String</api/data_types/string>`, value As `String</api/data_types/string>`)

> This syntax sets an attribute and declares a namespace.
>
> The following XML is stored in a constant called `kXML`:
>
> ``` XML
> <?xml version="1.0" encoding="UTF-8"?>
> <League>
>     <Team name="Seagulls">
>         <Player name="Bob" position="1B" />
>         <Player name="Tom" position="2B" />
>     </Team>
>     <Team name="Pigeons">
>         <Player name="Bill" position="1B" />
>         <Player name="Tim" position="2B" />
>     </Team>
>     <Team name="Crows">
>         <Player name="Ben" position="1B" />
>         <Player name="Ty" position="2B" />
>     </Team>
> </League>
> ```
>
> Add a "city" attribute to the first team:
>
> ``` Xojo
> Var xml As New XmlDocument(kXML)
> Var n As XmlNode = xml.DocumentElement.FirstChild
> n.SetAttribute("city", "Boston")
>
> TextArea1.Text = xml.ToString
> ```
>
> The result would then be:
>
> ``` XML
> <?xml version="1.0" encoding="UTF-8"?>
> <League>
>     <Team name="Seagulls" city="Boston">
>         <Player name="Bob" position="1B" />
>         <Player name="Tom" position="2B" />
>     </Team>
>     <Team name="Pigeons">
>         <Player name="Bill" position="1B" />
>         <Player name="Tim" position="2B" />
>     </Team>
>     <Team name="Crows">
>         <Player name="Ben" position="1B" />
>         <Player name="Ty" position="2B" />
>     </Team>
> </League>
> ```

<div id="xmlattribute.setattributenode">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

XMLAttribute.SetAttributeNode

**SetAttributeNode**(attributeNode As `XMLAttribute</api/text/xml/xmlattribute>`) As XMLAttribute

**SetAttributeNode**(attributeNode As `XMLAttribute</api/text/xml/xmlattribute>`)

> Sets an attribute node.
>
> SetAttributeNode optionally returns a reference to a node as an <span class="title-ref">XMLAttribute</span> that had the same name and was replaced.
>
> The following XML is stored in a constant called `kXML`:
>
> ``` XML
> <?xml version="1.0" encoding="UTF-8"?>
> <League>
>     <Team name="Seagulls">
>         <Player name="Bob" position="1B" />
>         <Player name="Tom" position="2B" />
>     </Team>
>     <Team name="Pigeons">
>         <Player name="Bill" position="1B" />
>         <Player name="Tim" position="2B" />
>     </Team>
>     <Team name="Crows">
>         <Player name="Ben" position="1B" />
>         <Player name="Ty" position="2B" />
>     </Team>
> </League>
> ```
>
> Adds a "city" attribute to the first team:
>
> ``` Xojo
> Var xml As New XmlDocument(kXML)
>
> Var n As XmlNode = xml.DocumentElement.FirstChild
>
> Var a As XmlAttribute
> a = xml.CreateAttribute("city")
> a.Value = "Boston"
>
> n.SetAttributeNode(a)
>
> TextArea1.Text = xml.ToString
> ```
>
> The result would then be:
>
> ``` XML
> <?xml version="1.0" encoding="UTF-8"?>
> <League>
>     <Team name="Seagulls" city="Boston">
>         <Player name="Bob" position="1B" />
>         <Player name="Tom" position="2B" />
>     </Team>
>     <Team name="Pigeons">
>         <Player name="Bill" position="1B" />
>         <Player name="Tim" position="2B" />
>     </Team>
>     <Team name="Crows">
>         <Player name="Ben" position="1B" />
>         <Player name="Ty" position="2B" />
>     </Team>
> </League>
> ```

<div id="xmlattribute.xql">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

XMLAttribute.XQL

**XQL**(query As `String</api/data_types/string>`) As `XMLNodeList</api/text/xml/xmlnodelist>`

**XQL**(query As `String</api/data_types/string>`, map() As `String</api/data_types/string>`) As `XMLNodeList</api/text/xml/xmlnodelist>`

> Performs an XPath 1.0 query and returns an `XMLNodeList</api/text/xml/xmlnodelist>` of the resulting nodes.
>
> If the *query* has namespace references in it, you must provide declarations for them in the form of a string array, such as:
>
> ``` xojo
> Var map() As String = Array("ns1","http://foo","ns2","http://bar")
> ```
>
> Xql is also called XPath. Version 1.0 of XPath are supported.
>
> For more information about XPath:
>
> - <https://www.w3schools.com/xml/xpath_intro.asp>
> - <http://www.w3.org/TR/xpath/>
>
> The example code below uses this XML. Assign it to a constant called `kTestXml`:
>
> ``` XML
> <?xml version="1.0" encoding="UTF-8"?>
> <League>
>     <Team name="Seagulls">
>         <Player name="Bob" position="1B" />
>         <Player name="Tom" position="2B" />
>     </Team>
>     <Team name="Pigeons">
>         <Player name="Bill" position="1B" />
>         <Player name="Tim" position="2B" />
>     </Team>
>     <Team name="Crows">
>         <Player name="Who" position="1B" />
>         <Player name="What" position="2B" />
>         <Player name="I Don't Know" position="3B" />
>     </Team>
> </League>
> ```
>
> To get all the player names, you can use "//Player" as the query:
>
> ``` Xojo
> ' Load XML
> Var xml As New XmlDocument
> Try
> xml.LoadXml(kTestXml)
> Catch e As XmlException
> MessageBox("XML error: " + e.Message)
> End Try
>
> ' Display all the Player names
> Var nodes As XmlNodeList
> nodes = xml.XQL("//Player") ' Find all Player nodes in XML
>
> ' Loop through results and display each name attribute
> Var node As XmlNode
> For i As Integer = 0 To nodes.Length - 1
> node = nodes.Item(i)
> MessageBox("Player: " + node.GetAttribute("name"))
> Next
> ```

## Notes

To retrieve attributes by index, use `XMLElement's</api/text/xml/xmlelement>` GetAttributeNode method.

## Sample code

The following XML is stored in a constant called `kXML`:

``` XML
<?xml version="1.0" encoding="UTF-8"?>
<League>
  <Team name="Seagulls">
      <Player name="Bob" position="1B" />
      <Player name="Tom" position="2B" />
  </Team>
  <Team name="Pigeons">
      <Player name="Bill" position="1B" />
      <Player name="Tim" position="2B" />
  </Team>
  <Team name="Crows">
      <Player name="Ben" position="1B" />
      <Player name="Ty" position="2B" />
  </Team>
</League>
```

To add an attribute to the first team node (Seagulls):

``` Xojo
Var xml As New XmlDocument(kXml)

' Create an attribute node and assign it a value
Var xa As XmlAttribute
xa = xml.CreateAttribute("TestAttribute")
xa.Value = "Test"

' Add the attribute to the XML document
xml.DocumentElement.FirstChild.SetAttributeNode(xa)

TextArea1.Text = xml.ToString
```

## Compatibility

|                       |     |
|-----------------------|-----|
| **Project Types**     | All |
| **Operating Systems** | All |

<div class="seealso">

`XMLNode</api/text/xml/xmlnode>` parent class; `XMLElement</api/text/xml/xmlelement>`, `XMLDocument</api/text/xml/xmldocument>`, `XMLNode</api/text/xml/xmlnode>` classes.

</div>
