CElement



Member Functions

CElement

   public:

CElement();

object constructor


CElement

   public:

CElement(const char* name);

object constructor

Parameters

NameDescription
namethe generic identifier for this element

addAttribute

   public:

void addAttribute(const char *attrName, const char* attrValue);

add an attribute and it's value to this object

Parameters

NameDescription
attrNamethe name of the attribute
attrValuethe value of the attribute

addCDataChunk

   public:

void addCDataChunk(const char* cdata, int len);

adds character data to this element

Parameters

NameDescription
cdatathe actual character string
lenthe length of this string

addChild

   public:

void addChild(CElement *child);

adds a CElement to the child list of this object

Parameters

NameDescription
childa pointer to the CElement to be added

findAllChildren

   public:

void findAllChildren(const char* elemName, const char* xnamespace, std::vector &kids, bool recurse=false);

finds all children that match the generic identifier passed in the function parameters

Parameters

NameDescription
elemNamethe generic identifier of the element to be found
xnamespacethe XML namespace
recuseif true, recurse the tree pree order to find the first. otherwise just scan immediate children
kidsa vector of CElement* to populate with the elements that match

findFirstChild

   public:

CElement *findFirstChild(const char* elemName, const char* xnamespace, bool rescurse);

a utility function that will find the first child that matches the generic identifier passed in the function parameters

Parameters

NameDescription
elemNamethe generic identifier of the element to be found
xnamespacethe XML namespace
recuseif true, recurse the tree pree order to find the first. otherwise just scan immediate children
Result: a pointer to a CElement object or NULL

getAttributes

   public:

std::vector& getAttributes();

returns a vector containing all of the attributes of this elements

Result: a reference to a std::vector

getCDATAasString

   public:

void getCDATAasString(std::string& content);

concatenates all of the CDATA chunks contained by this element

Parameters

NameDescription
contentan output parameter where the character data is copied into

getChildren

   public:

std::vector & getChildren();

get a vector containing all of the CElement objects of which this object is the immediate parent

Result: a reference to a std::vector

getDATA

   public:

std::vector& getCDATA();

returns a vector of all of the CDATA chunks contained by this element

Result: a reference to a std::vector

getLanguage

   public:

const char* getLanguage();


getMixedContentAsXML

   public:

void getMixedContentAsXML(std::string &mixedContent);

concatenates all of the CDATA chunks and elements contained by this element and returns a syntactically valid XML document fragment

Parameters

NameDescription
mixedContentthe string where the document fragment is returned

getParent

   public:

CElement* getParent();

gets the parent of this element

Result: a pointer to a CElement or NULL if this is the root of the document

setLanguage

   public:

void setLanguage(const char* lang);

Parameters

NameDescription
langthe language

setParent

   public:

void setParent(CElement *elem);

sets the parent of this element

Parameters

NameDescription
elema pointer to the parent element

~CElement

   public:

virtual ~CElement();

object destructor


Member Data

m_attributes

protected:
 std::vector m_attributes;

all attributes of this element


m_cdataChunks

protected:
 std::vector m_cdataChunks;

all chunks of CDATA contained by this element


m_children

protected:
 std::vector m_children;

all direct children elements


m_lang

protected:
 std::string m_lang; 

the contents of an xml:lang attribute, if any


m_parent

protected:
 CElement *m_parent;

the parent element


nMixedModel

protected:
 std::vector mMixedModel;

all CDATA chunks and elements contained by this element in the order encounted during the parse of the document


© 1999-2000, Thomas Bednarz, Jr. — (Last Updated 7/16/2000)