XMLNode¶
Bases: object
XMLNode class represents a node in an XML document.
This class allows tree traversal, manipulation, and access to attributes and children of an XML element.
__init__(*args)
¶
Overload 1:
Default constructor.
|
Overload 2:
Copy constructor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node
|
XMLNode
|
The XMLNode to copy |
required |
addChild(*args)
¶
Add a child node.
Creates and returns a child node with a specified name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
childName
|
string
|
The name of the child node |
required |
Returns:
| Type | Description |
|---|---|
XMLNode
|
The created child XML node |
removeChild(childName)
¶
Remove a child node.
Removes the first child node matching the specified name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
childName
|
string
|
The name of the child node to remove |
required |
getChild(name)
¶
Get a child node.
Retrieves the first child node with the specified name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
string
|
The name of the child node |
required |
Returns:
| Type | Description |
|---|---|
XMLNode
|
The child XML node |
getChildren(*args)
¶
Overload 1:
Get all children with a specific name.
Retrieves all child nodes matching the specified name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
string
|
The name of the child nodes |
required |
Returns:
| Type | Description |
|---|---|
list[XMLNode]
|
The list of all child XML nodes |
setName(name)
¶
Set the node name.
Sets the name of this XML node.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
string
|
The name for the node |
required |
getName()
¶
Get the node name.
Retrieves the name of this XML node.
Returns:
| Type | Description |
|---|---|
str
|
The name of the node |
isEmpty()
¶
Check if node is empty.
Check if the node is empty.
Returns:
| Type | Description |
|---|---|
boolean
|
True if the node is empty, false otherwise |
addAttribute(*args)
¶
Overload 1:
Add a string attribute.
Adds a string attribute to the node.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
string
|
The name of the attribute |
required |
value
|
string
|
The string value of the attribute | Overload 2: Add a boolean attribute. Adds a boolean attribute to the node. |
required |
getAttribute(name)
¶
Get an attribute.
Retrieves the attribute with the specified name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
string
|
The name of the attribute |
required |
Returns:
| Type | Description |
|---|---|
XMLAttribute
|
The XML attribute |
getAttributes()
¶
Get all attributes.
Retrieves all attributes of this node.
Returns:
| Type | Description |
|---|---|
list[XMLAttribute]
|
The list of XML attributes |