# class XmlElement | Xml Element. More...
Full name | `TelEngine::XmlElement`
Definition | `#include <libs/yxml/yatexml.h>`
Inherits | TelEngine::XmlChild [public ], TelEngine::XmlParent [public ]
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

#### Public Methods

- XmlElement (const NamedList& element, bool empty, XmlParent* parent = 0)
- XmlElement (const char* name, bool complete = true)
- XmlElement (const char* name, const char* value, bool complete = true)
- XmlElement (const XmlElement& orig)
- virtual ~XmlElement ()
- inline const char* tag () const
- inline bool isDefaultNs () const
- inline const String& unprefixedTag () const
- void setUnprefixedTag (const String& s)
- inline const String& getTag () const
- bool getTag (const String*& tag, const String*& ns) const
- virtual XmlElement* xmlElement ()
- virtual XmlElement* element ()
- virtual XmlSaxParser::Error addChild (XmlChild* child)
- virtual XmlChild* removeChild (XmlChild* child, bool delObj = true)
- virtual void setCompleted ()
- inline bool completed () const
- inline bool empty () const
- inline XmlElement* parent () const
- virtual XmlParent* getParent ()
- virtual void setParent (XmlParent* parent)
- virtual const String& getName () const
- virtual const NamedList& getElement () const
- inline const ObjList& getChildren () const
- inline void clearChildren ()
- inline const NamedList* inheritedNs () const
- void setInheritedNs (const XmlElement* xml = 0, bool inherit = true)
- void addInheritedNs (const NamedList& list)
- inline XmlElement* pop ()
- virtual const String& toString () const
- void toString (String& dump, bool escape = true, const String& indent = String::empty(), const String& origIndent = String::empty(), bool completeOnly = true, const String* auth = 0) const
- inline XmlElement* findFirstChild (const String* name = 0, const String* ns = 0, bool noPrefix = true) const
- inline XmlElement* findNextChild (XmlElement* prev = 0, const String* name = 0, const String* ns = 0, bool noPrefix = true) const
- inline const String* childText (const String& name, const String* ns = 0, bool noPrefix = true) const
- XmlChild* getFirstChild ()
- const String& getText () const
- XmlText* setText (const char* text)
- void addText (const char* text)
- inline const NamedList& attributes () const
- unsigned int copyAttributes (NamedList& list, const String& prefix) const
- void setAttributes (NamedList& list, const String& prefix, bool skipPrefix = true)
- inline void setAttribute (const String& name, const char* value)
- inline void setAttributeValid (const String& name, const char* value)
- inline const char* attribute (const String& name) const
- inline String* getAttribute (const String& name) const
- inline bool hasAttribute (const String& name, const String& value) const
- inline void removeAttribute (const String& name)
- inline String* xmlns () const
- String* xmlnsAttribute (const String& name) const
- inline bool hasXmlns (const String& ns) const
- bool setXmlns (const String& name = String::empty(), bool addAttr = false, const String& value = String::empty())

#### Public Static Methods

- static inline bool isXmlns (const String& str)
- static XmlElement* param2xml (NamedString* param, const String& tag, bool copyXml = false)
- static NamedString* xml2param (XmlElement* xml, const String* tag, bool copyXml = false)
- static void xml2param (NamedList& list, XmlElement* parent, const String* tag, bool copyXml = false)

#### Public Members

- static const String s_ns
- static const String s_nsPrefix

## Detailed Description

Xml Element from a Xml document

XmlElement (const NamedList& element, bool empty, XmlParent* parent = 0) | ### XmlElement

Constructor

Parameters:

element | The NamedList name represent the element name and the param the attributes
empty | False if has children
parent | The parent of this element

XmlElement (const char* name, bool complete = true) | ### XmlElement

Constructor. Creates a new complete and empty element

Parameters:

name | The name of the element
complete | False to build an incomplete element

XmlElement (const char* name, const char* value, bool complete = true) | ### XmlElement

Constructor. Create a new element with a text child

Parameters:

name | The name of the element
value | Element text child value
complete | False to build an incomplete element

XmlElement (const XmlElement& orig) | ### XmlElement

Copy constructor

Parameters:

orig | Original XmlElement

~XmlElement () | ### ~XmlElement

[virtual]

Destructor

inline const char* tag () | ### tag

[const]

Retrieve the element's tag

Returns: The element's tag

inline bool isDefaultNs () | ### isDefaultNs

[const]

Check if this element must be processed in the default namespace (its tag is not prefixed)

Returns: True if this element must be processed in the default namespace

inline const String& unprefixedTag () | ### unprefixedTag

[const]

Retrieve the element's tag unprefixed (namespace prefix removed)

Returns: The element's tag unprefixed

void setUnprefixedTag (const String& s) | ### setUnprefixedTag

Set element's unprefixed tag, don't change namespace prefix

Parameters:

s | New element's tag

inline const String& getTag () | ### getTag

[const]

Retrieve the element's tag (without prefix)

Returns: Element tag

bool getTag (const String*& tag, const String*& ns) | ### getTag

[const]

Retrieve the element's tag (without prefix) and namespace

Parameters:

tag | Pointer to element tag
ns | Pointer to element's namespace (may be 0 for unprefixed tags)

Returns: True if a namespace was found for the element tag or the tag is not prefixed

XmlElement* xmlElement () | ### xmlElement

[virtual]

Get an XmlElement from this XmlChild

Returns: This object

Reimplemented from XmlChild.

XmlElement* element () | ### element

[virtual]

Get an XmlElement from this XmlParent

Returns: This object

Reimplemented from XmlParent.

XmlSaxParser::Error addChild (XmlChild* child) | ### addChild

[virtual]

Append a new child of this element

Parameters:

child | The child to append

Reimplemented from XmlParent.

XmlChild* removeChild (XmlChild* child, bool delObj = true) | ### removeChild

[virtual]

Remove a child

Parameters:

child | The child to remove
delObj | True to delete the object

Returns: XmlChild pointer if found and not deleted

Reimplemented from XmlParent.

void setCompleted () | ### setCompleted

[virtual]

Notification for this element that is complete

inline bool completed () | ### completed

[const]

Returns: True if this element is completed

inline bool empty () | ### empty

[const]

Returns: True if this element is empty

inline XmlElement* parent () | ### parent

[const]

Retrieve an XmlElement parent of this one

Returns: XmlElement pointer or 0

XmlParent* getParent () | ### getParent

[virtual]

Returns: The parent of this element

void setParent (XmlParent* parent) | ### setParent

[virtual]

Set this element's parent. Update inherited namespaces

Returns: The parent of this element

Reimplemented from XmlChild.

const String& getName () | ### getName

[const virtual]

Returns: The name of this element

const NamedList& getElement () | ### getElement

[const virtual]

Returns: The held element

inline const ObjList& getChildren () | ### getChildren

[const]

Helper method to obtain the children list

Returns: The children list

Reimplemented from XmlParent.

inline void clearChildren () | ### clearChildren

Helper method to clear the children list

Reimplemented from XmlParent.

inline const NamedList* inheritedNs () | ### inheritedNs

[const]

Retrieve the list of inherited namespaces

Returns: The list of inherited namespaces (or 0)

void setInheritedNs (const XmlElement* xml = 0, bool inherit = true) | ### setInheritedNs

Set inherited namespaces from a given element. Reset them anyway

Parameters:

xml | The source element used to set inherited namespaces
inherit | Copy element's inherited namespaces if it doesn't have a parent

void addInheritedNs (const NamedList& list) | ### addInheritedNs

Add inherited namespaces from a list

Parameters:

list | The list of namespaces

inline XmlElement* pop () | ### pop

Extract the first child element

Returns: XmlElement pointer or 0

const String& toString () | ### toString

[const virtual]

Retrieve the element tag

Returns: The element tag

Reimplemented from GenObject.

void toString (String& dump, bool escape = true, const String& indent = String::empty(), const String& origIndent = String::empty(), bool completeOnly = true, const String* auth = 0) | ### toString

[const]

Build (append to) a String from this XmlElement

Parameters:

dump | The destination string
escape | True if the attributes values need to be escaped
indent | Spaces for output
origIndent | Original indent
completeOnly | True to build only if complete
auth | Optional list of tag and attribute names to be replaced with '***'. This parameter can be used when the result will be printed to output to avoid printing authentication data to output. The array must end with an empty string

Reimplemented from GenObject.

inline XmlElement* findFirstChild (const String* name = 0, const String* ns = 0, bool noPrefix = true) | ### findFirstChild

[const]

Find the first XmlElement child of this XmlElement

Parameters:

name | Optional name of the child
ns | Optional child namespace
noPrefix | True to compare the tag without namespace prefix, false to include namespace prefix when comparing the given tag. This parameter is ignored if name is 0 or ns is not 0

Returns: The first child element meeting the requested conditions

inline XmlElement* findNextChild (XmlElement* prev = 0, const String* name = 0, const String* ns = 0, bool noPrefix = true) | ### findNextChild

[const]

Finds next XmlElement child of this XmlElement

Parameters:

prev | Previous child
name | Optional name of the child
ns | Optional child namespace
noPrefix | True to compare the tag without namespace prefix, false to include namespace prefix when comparing the given tag. This parameter is ignored if name is 0 or ns is not 0

Returns: The next found child if prev exists else the first

inline const String* childText (const String& name, const String* ns = 0, bool noPrefix = true) | ### childText

[const]

Retrieve a child's text

Parameters:

name | Name (tag) of the child
ns | Optional child namespace
noPrefix | True to compare the tag without namespace prefix, false to include namespace prefix when comparing the given tag. This parameter is ignored ns is not 0

Returns: Pointer to child's text, 0 if the child was not found

XmlChild* getFirstChild () | ### getFirstChild

Get first XmlChild of this XmlElement

Returns: The first XmlChild found.

const String& getText () | ### getText

[const]

Returns: The first XmlText found in this XmlElement children

XmlText* setText (const char* text) | ### setText

Set text for first XmlText element found in this XmlElement's children If child text element does not exist, create it and append it to the element's children.

Parameters:

text | Text to set to the XmlElement. If null, the first found XmlText element will be deleted.

Returns: The set XmlText if text was set, null if an XmlText was deleted

void addText (const char* text) | ### addText

Add a text child

Parameters:

text | Non empty text to add

inline const NamedList& attributes () | ### attributes

[const]

Retrieve the list of attributes

Returns: Element attributes

unsigned int copyAttributes (NamedList& list, const String& prefix) | ### copyAttributes

[const]

Copy element attributes to a list of parameters

Parameters:

list | Destination list
prefix | Prefix to be added to each attribute name

Returns: The number of attributes added to the destination list

void setAttributes (NamedList& list, const String& prefix, bool skipPrefix = true) | ### setAttributes

Set element attributes from a list of parameters

Parameters:

list | List of attributes
prefix | Add only the attributes that start with this prefix. = If NULL, it will set as attributes the whole parameter list
skipPrefix | Skip over the prefix when building attribute name

inline void setAttribute (const String& name, const char* value) | ### setAttribute

Add or replace an attribute

Parameters:

name | Attribute name
value | Attribute value

inline void setAttributeValid (const String& name, const char* value) | ### setAttributeValid

Add or replace an attribute. Clears it if value is empty

Parameters:

name | Attribute name
value | Attribute value

inline const char* attribute (const String& name) | ### attribute

[const]

Obtain an attribute value for the given name

Parameters:

name | The name of the attribute

Returns: Attribute value

inline String* getAttribute (const String& name) | ### getAttribute

[const]

Obtain an attribute value for the given name

Parameters:

name | The name of the attribute

Returns: String pointer or 0 if not found

inline bool hasAttribute (const String& name, const String& value) | ### hasAttribute

[const]

Check if the element has an attribute with a requested value

Parameters:

name | The name of the attribute
value | The value to check

Returns: True if the element has an attribute with the requested value

inline void removeAttribute (const String& name) | ### removeAttribute

Remove an attribute

Parameters:

name | Attribute name

inline String* xmlns () | ### xmlns

[const]

Retrieve the element's namespace

Returns: Element's namespace or 0 if not found

String* xmlnsAttribute (const String& name) | ### xmlnsAttribute

[const]

Retrieve a namespace attribute. Search in parent or inherited for it

Returns: String pointer or 0 if not found

inline bool hasXmlns (const String& ns) | ### hasXmlns

[const]

Verify if this element belongs to the given namespace

Parameters:

ns | The namespace to compare with

Returns: True if this element belongs to the given namespace

bool setXmlns (const String& name = String::empty(), bool addAttr = false, const String& value = String::empty()) | ### setXmlns

Set the element's namespace

Parameters:

name | The namespace name (element prefix). Can be the default namespace attribute name (empty means the default one)
addAttr | True to add a non empty, not repeating, namespace attribute to the list
value | Namespace value (ignored if addAttr is false)

Returns: True on success, false if another namespace exists with the same value

inline bool isXmlns (const String& str) | ### isXmlns

[static]

Check if a string represents a namespace attribute name

Parameters:

str | The string to check

Returns: True if the given string is the default namespace attribute name or a namespace attribute name prefix

XmlElement* param2xml (NamedString* param, const String& tag, bool copyXml = false) | ### param2xml

[static]

Build an XML element from a list parameter. Parameter name will be set in a 'name' attribute. Parameter value will be set in a 'value' attribute Handle NamedPointer parameters carrying DataBlock, NamedList and XmlElement objects (a 'type' attribute is added to the created element). DataBlock: Encode using BASE64 and add it as element text NamedList: The name is added as element text. The function is called again for each list parameter XmlElement: Added as child to newly created element

Parameters:

param | The parameter to convert
tag | XmlElement tag
copyXml | True to copy XmlElement objects instead of just remove them from the parameter

Returns: XmlElement pointer or 0 on failure

NamedString* xml2param (XmlElement* xml, const String* tag, bool copyXml = false) | ### xml2param

[static]

Build a list parameter from xml element See param2xml for more info

Parameters:

xml | The XML element to process
tag | Child XmlElement tag to handle
copyXml | True to copy XmlElement objects instead of just remove them from parent

Returns: NamedString pointer or 0 on failure

void xml2param (NamedList& list, XmlElement* parent, const String* tag, bool copyXml = false) | ### xml2param

[static]

Build and add list parameters from XML element children. Each parameter will be taken from 'name' and 'value' attributes. See param2xml for more info

Parameters:

list | Destination list
parent | The XML element to process
tag | Child XmlElement tag to handle
copyXml | True to copy XmlElement objects instead of just remove them from parent

static const String s_ns | ### s_ns

static const String s_nsPrefix | ### s_nsPrefix

Generated by: paulc on bussard on Mon Feb 10 13:15:47 2014, using kdoc 2.0a54.