Skip to content

Inscoper::XMLNode

XMLNode class represents a node in an XML document. More...

#include <XMLNode.h>

Public Functions

Name
XMLNode()
Default constructor.
XMLNode(XMLNode const & node)
Copy constructor.
XMLNode(XMLNode && node)
Move constructor.
XMLNode & operator=(XMLNode const & node)
Copy assignment operator.
XMLNode & operator=(XMLNode && node)
Move assignment operator.
~XMLNode()
Destructor.
XMLNode addChild(std::string childName ="")
Add a child node.
void removeChild(std::string childName)
Remove a child node.
XMLNode getChild(const std::string & name)
Get a child node.
std::vector< XMLNode > getChildren(const std::string & name)
Get all children with a specific name.
std::vector< XMLNode > getChildren()
Get all children.
void setName(const std::string & name)
Set the node name.
std::string getName()
Get the node name.
bool isEmpty()
Check if node is empty.
void addAttribute(const std::string & name, const std::string & value)
Add a string attribute.
void addAttribute(const std::string & name, const bool value)
Add a boolean attribute.
void addAttribute(const std::string & name, const unsigned int value)
Add an unsigned int attribute.
void addAttribute(const std::string & name, const unsigned short value)
Add an unsigned short attribute.
void addAttribute(const std::string & name, unsigned char value)
Add an unsigned char attribute.
void addAttribute(const std::string & name, char value)
Add a char attribute.
void addAttribute(const std::string & name, double value)
Add a double attribute.
Inscoper::XMLAttribute getAttribute(const std::string & name)
Get an attribute.
std::vector< Inscoper::XMLAttribute > getAttributes()
Get all attributes.

Friends

Name
class XMLDocument

Detailed Description

class Inscoper::XMLNode;

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.

Public Functions Documentation

function XMLNode

XMLNode()

Default constructor.

function XMLNode

XMLNode(
    XMLNode const & node
)

Copy constructor.

Parameters:

function XMLNode

XMLNode(
    XMLNode && node
)

Move constructor.

Parameters:

function operator=

XMLNode & operator=(
    XMLNode const & node
)

Copy assignment operator.

Parameters:

Return: Reference to this XMLNode

function operator=

XMLNode & operator=(
    XMLNode && node
)

Move assignment operator.

Parameters:

Return: Reference to this XMLNode

function ~XMLNode

~XMLNode()

Destructor.

function addChild

XMLNode addChild(
    std::string childName =""
)

Add a child node.

Parameters:

  • childName : The name of the child node

Return: The created child XML node

Creates and returns a child node with a specified name.

function removeChild

void removeChild(
    std::string childName
)

Remove a child node.

Parameters:

  • childName : The name of the child node to remove

Removes the first child node matching the specified name.

function getChild

XMLNode getChild(
    const std::string & name
)

Get a child node.

Parameters:

  • name : The name of the child node

Return: The child XML node

Retrieves the first child node with the specified name.

function getChildren

std::vector< XMLNode > getChildren(
    const std::string & name
)

Get all children with a specific name.

Parameters:

  • name : The name of the child nodes

Return: The list of matching XML nodes

Retrieves all child nodes matching the specified name.

function getChildren

std::vector< XMLNode > getChildren()

Get all children.

Return: The list of all child XML nodes

Retrieves all child nodes of this node.

function setName

void setName(
    const std::string & name
)

Set the node name.

Parameters:

  • name : The name for the node

Sets the name of this XML node.

function getName

std::string getName()

Get the node name.

Return: The name of the node

Retrieves the name of this XML node.

function isEmpty

bool isEmpty()

Check if node is empty.

Return: True if the node is empty, false otherwise

Check if the node is empty.

function addAttribute

void addAttribute(
    const std::string & name,
    const std::string & value
)

Add a string attribute.

Parameters:

  • name : The name of the attribute
  • value : The string value of the attribute

Adds a string attribute to the node.

function addAttribute

void addAttribute(
    const std::string & name,
    const bool value
)

Add a boolean attribute.

Parameters:

  • name : The name of the attribute
  • value : The boolean value of the attribute

Adds a boolean attribute to the node.

function addAttribute

void addAttribute(
    const std::string & name,
    const unsigned int value
)

Add an unsigned int attribute.

Parameters:

  • name : The name of the attribute
  • value : The unsigned int value of the attribute

Adds an unsigned int attribute to the node.

function addAttribute

void addAttribute(
    const std::string & name,
    const unsigned short value
)

Add an unsigned short attribute.

Parameters:

  • name : The name of the attribute
  • value : The unsigned short value of the attribute

Adds an unsigned short attribute to the node.

function addAttribute

void addAttribute(
    const std::string & name,
    unsigned char value
)

Add an unsigned char attribute.

Parameters:

  • name : The name of the attribute
  • value : The unsigned char value of the attribute

Adds an unsigned char attribute to the node.

function addAttribute

void addAttribute(
    const std::string & name,
    char value
)

Add a char attribute.

Parameters:

  • name : The name of the attribute
  • value : The char value of the attribute

Adds a char attribute to the node.

function addAttribute

void addAttribute(
    const std::string & name,
    double value
)

Add a double attribute.

Parameters:

  • name : The name of the attribute
  • value : The double value of the attribute

Adds a double attribute to the node.

function getAttribute

Inscoper::XMLAttribute getAttribute(
    const std::string & name
)

Get an attribute.

Parameters:

  • name : The name of the attribute

Return: The XML attribute

Retrieves the attribute with the specified name.

function getAttributes

std::vector< Inscoper::XMLAttribute > getAttributes()

Get all attributes.

Return: The list of XML attributes

Retrieves all attributes of this node.

Friends

friend XMLDocument

friend class XMLDocument(
    XMLDocument 
);

Updated on 2026-04-02 at 10:55:36 +0200