UI::GXML::Tree::Node Class Reference

A XML node. More...

`#include <Tree.hpp>`

Inheritance diagram for UI::GXML::Tree::Node:
Collaboration diagram for UI::GXML::Tree::Node:

## Public Types

typedef xmlElementType | Type
| Abstract from libxml2 type.

## Public Member Functions

| Node (xmlNode *const node=0)
| Constructor from libxml2 node.
bool | isNull () const
| Test if this is null ("not a tree node").
void | unlink ()
| Unlink this node (from underlying tree). Memory will be freed, and the node becomes a null node.
NodeSet | getChilds (std::string const &name="") const
| Get all child nodes of this node.
Type | getType () const
| Get node type.
std::string | getXPath () const
| Get associated XPath.
char const * | hasAttribute (std::string const &name) const
| Returns 0 if not found, else the attribute's content.
char const * | getAttributeC (std::string const &name) const
| Like above, but always return valid c string (length 0 if not found).
std::string | getAttribute (std::string const &name) const
| Like above, but return std::string.
void | setAttribute (std::string const &name, std::string const &content)
Node | addChild (std::string const &name, std::string const &content="")
| Add a new (element) child node.
Node | addChild (Node const &n)
| Add a (deep) copy of this node.
Node | addSiblingAfter (std::string const &name, std::string const &content)
| Add a new (element) sibling node.
Node | addSiblingAfter (Node const &n)
| Add a (deep) copy of this node as a sibling.
std::string | dump (bool const &format=false, std::string const &encoding=DefaultEncoding_) const
| Dump shortcut.
Navigate through the tree.
Node | getParent () const
Node | getChild () const
Node | getNext () const
Node | getPrev () const
Get/set name of node.
char const * | getNameC () const
std::string | getName () const
void | setName (std::string const &name)
Get/set text content of first child node.
char const * | getContentC () const
std::string | getContent () const
void | setContent (std::string const &content)
Xpath evaluation on this node.
NodeSet | getNodeSet (std::string const &xpath) const
Node | getNode (std::string const &xpath, bool const &doThrow=true) const

## Friends

class | NodeSet

## Detailed Description

A XML node.

Examples
  UnitTests.cpp.

## Member Function Documentation

## getNameC()

char const * UI::GXML::Tree::Node::getNameC | ( |  | ) | const

Note
  Set will only work for element nodes.

## getNodeSet()

Tree::NodeSet UI::GXML::Tree::Node::getNodeSet | ( | std::string const & | xpath | ) | const

Note
  XPathContext is created each time we call => thread-safe, but possibly non-performant. A solution like in Tree would be better, or even some other more general solution for both Tree + Tree::Node.

References UI::GXML::Tree::XPathContext.

## getParent()

Tree::Node UI::GXML::Tree::Node::getParent | ( |  | ) | const

If a node does not exists, the returned node isNull().

References Node().

## setName()

void UI::GXML::Tree::Node::setName | ( | std::string const & | name | ) |

Bug
  Imho, this should also work for attribute nodes, but this currently segfaults.

References getType().

The documentation for this class was generated from the following files:

- Tree.hpp
- Tree.cpp