Modeler Extensions Framework
XMLElement Class Reference
Inheritance diagram for XMLElement:
XMLDocument

Public Member Functions

 XMLElement (CLEMEXTXML *item=NULL)
 
virtual ~XMLElement ()
 
void getName (std::string &name)
 
bool hasAttribute (const std::string &name)
 
void getAttribute (const std::string &name, std::string &value)
 
std::string getAttribute (const std::string &name)
 
XMLElement getElementByAttribute (const std::string name, const std::string &attr_name, const std::string attr_value)
 
bool getAttribute (const std::string &name, CLEMEXTReal &value)
 
bool getAttribute (const std::string &name, CLEMEXTInteger &value)
 
void addAttribute (const std::string &name, const std::string &value)
 
void addAttribute (const std::string &name, CLEMEXTInteger value)
 
void removeAttribute (const std::string &name)
 
XMLElementIterator getElements (const std::string &name)
 
XMLTextIterator getTextSections ()
 
XMLElement addElement (const std::string &name)
 
void addText (const std::string &data)
 
bool isValid () const
 
XMLElement getElement (const std::string &name)
 
XMLElement getElement (const std::string &name, int index)
 

Protected Attributes

CLEMEXTXML * item_
 

Detailed Description

a class wrapping an XML element, allowing attributes and elements to be queried and extended

Definition at line 129 of file XMLHelper.h.

Constructor & Destructor Documentation

XMLElement ( CLEMEXTXML *  item = NULL)

create from a CLEMEXT C-API object

Parameters
itemthe CLEMEXT C-API object pointer representing an XML element
virtual ~XMLElement ( )
virtual

destroy, but do not delete the underlying CLEMEXTXML object

Member Function Documentation

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

add an attribute

Parameters
namethe name of the attribute
valuethe value of the attribute
void addAttribute ( const std::string &  name,
CLEMEXTInteger  value 
)

add an attribute

Parameters
namethe name of the attribute
valuethe value of the attribute
XMLElement addElement ( const std::string &  name)

add a new child element to this element

Parameters
namethe name of the element
Returns
pointer to a new XMLElement object
void addText ( const std::string &  data)

add new text to the element

Parameters
datatext string to add
void getAttribute ( const std::string &  name,
std::string &  value 
)

return the value of an attribute

Parameters
namethe name of the attribute
valuereference to a string in which to return the attribute value (or empty string if the attribute does not exist)
std::string getAttribute ( const std::string &  name)

convenience method - same as getAttribute(string, string) but return attribute value directly as a string.

bool getAttribute ( const std::string &  name,
CLEMEXTReal value 
)

return the value of an attribute as a double precision number

Parameters
namethe name of the attribute
valuereference to a CEFReal in which to return the attribute value (or 0.0 if the attribute does not exist)
Returns
false iff value cannot be converted to a double precision number
bool getAttribute ( const std::string &  name,
CLEMEXTInteger value 
)

return the value of an attribute as a 64-bit signed integer

Parameters
namethe name of the attribute
valuereference to a CEFInteger in which to return the attribute value (or 0.0 if the attribute does not exist)
Returns
false iff value cannot be converted to an integer
XMLElement getElement ( const std::string &  name)

gets the sub-element with the specified name. Will only retrieve immediate children. If there is more than one node with this name, retrieves only the first one. If the element doesn't exist, throws an XMLException (with message).

XMLElement getElement ( const std::string &  name,
int  index 
)

gets the sub-element with the specified name and index. Will only retrieve immediate children. If the element doesn't exist, throws an XMLException (with message).

XMLElement getElementByAttribute ( const std::string  name,
const std::string &  attr_name,
const std::string  attr_value 
)

Get the child element with the specified name possessing an attribute with the specified attribute name and value.

XMLElementIterator getElements ( const std::string &  name)

open an iterator over a subset of the element's child elements

Parameters
namethe name of the child elements to iterate over
Returns
pointer to an XMLIterator object from which child elements can be retrieved
See also
XMLElementIterator
void getName ( std::string &  name)

return the name of this element

Parameters
namereturn name of the element in referenced string
XMLTextIterator getTextSections ( )

open an iterator over a subset of the element's character data sections

Returns
pointer to an XMLTextIterator object from which child elements can be retrieved
See also
XMLTextIterator
bool hasAttribute ( const std::string &  name)

does the element have an attribute?

Parameters
namethe name of the attribute to test
Returns
true iff the attribute exists
bool isValid ( ) const

does this document contain valid XML

Returns
true iff document is valid
void removeAttribute ( const std::string &  name)

remove an attribute (if it exists)

Parameters
namethe name of the attribute

Field Documentation

CLEMEXTXML* item_
protected

Definition at line 131 of file XMLHelper.h.


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