XMLNODE Class Reference

This class is an interface-only class to allow us to treat an xmlNodePtr as a (NODE*) Constructor/CopyConstructor/Destructor all unimplemented Memory allocation done through library calls, not new/delete. More...

#include <mi32/xml.h>

List of all members.

Public Member Functions

void AddComment (const MIUNICODE *)
void AppendText (const MIUNICODE *text)
void Attach (XMLNODE *parent)
XMLNODECopy (bool recursive=true, XMLDOC *NewDoc=NULL) const
void Delete ()
void DeleteAllChildren ()
void Detach ()
XMLNODEFindChild (const char *TagName, const char *PropertyName, const char *PropertyValue) const
XMLNODEFindChild (const char *TagName, const char *PropertyName, const MIUNICODE *PropertyValue) const
XMLNODEFindChild (const char *TagName) const
XMLNODEFindNext (const char *TagName=0, const char *PropName=0, const char *PropValue=0) const
bool GetContentXML (STRUTF8 &retstr, bool bIncludeSelf, bool bFormat=true, int indent=0)
bool GetContentXML (MISTRING &retstr, bool bIncludeSelf, bool bFormat=true, int indent=0)
XMLNODEGetElementByAttribute (const char *AttributeName, const char *AttributeValue) const
XMLNODEGetElementByAttribute (const char *AttributeName, const MIUNICODE *AttributeValue) const
bool GetElementsByTagName (SIMPLE_ARRAY< XMLNODE * > &Nodes, const char *TagName, bool bCaseSensitive=true) const
XMLNODEGetFirstChild () const
XMLNODEGetLastChild () const
const char * GetName () const
XMLNODEGetNext () const
XMLNODEGetParent () const
XMLNODEGetPrevious () const
bool GetProperty (const char *PropName, UINT64 &retvalue, bool bCaseSensitive=true) const
bool GetProperty (const char *PropName, INT64 &retvalue, bool bCaseSensitive=true) const
bool GetProperty (const char *PropName, UINT32 &retvalue, bool bCaseSensitive=true) const
bool GetProperty (const char *PropName, INT32 &retvalue, bool bCaseSensitive=true) const
bool GetProperty (const char *PropName, double &retvalue, bool bCaseSensitive=true) const
bool GetProperty (const char *PropName, bool &retvalue, bool bCaseSensitive=true) const
bool GetProperty (const char *PropName, STRUTF8 &retstr, bool bCaseSensitive=true) const
bool GetProperty (const char *PropName, MISTRING &str, bool bCaseSensitive=true) const
bool GetPropertyBool (const char *PropName, bool dft=false, bool bCaseSensitive=true) const
double GetPropertyNum (const char *PropName, double dft=0.0, bool bCaseSensitive=true) const
bool GetText (STRUTF8 &str, bool bStripLeadingAndTrailingWhitespace=true) const
bool GetText (MISTRING &str, bool bStripLeadingAndTrailingWhitespace=true) const
bool GetValue (UINT64 &retvalue) const
bool GetValue (INT64 &retvalue) const
bool GetValue (UINT32 &retvalue) const
bool GetValue (INT32 &retvalue) const
bool GetValue (double &retvalue) const
bool GetValue (bool &retvalue) const
bool HasProperty (const char *name, bool bCaseSensitive=true) const
bool IsCDATA () const
bool IsEmpty () const
bool IsText () const
XMLNODENewCDATAChild (const char *TagName, const UINT8 *value, int len=-1, XMLNAMESPACE *pNameSpace=0)
XMLNODENewCDATAChild (const char *TagName, const MIUNICODE *value, XMLNAMESPACE *pNameSpace=0)
XMLNODENewChild (const XMLNODE *NodeToCopy)
XMLNODENewChild (const char *TagName, double value, MISTRING::FLOATFMT floatfmt=MISTRING::FLOATFMT_MaxPrecision, XMLNAMESPACE *pNameSpace=0)
XMLNODENewChild (const char *TagName, const MIUNICODE *value, XMLNAMESPACE *pNameSpace=0)
XMLNODENewChild (const char *TagName, XMLNAMESPACE *pNameSpace=0)
XMLNODENewTextChild (const char *TagName, const char *value, XMLNAMESPACE *pNameSpace=0)
XMLNODENewTextChild (const char *TagName, const MIUNICODE *value, XMLNAMESPACE *pNameSpace=0)
void Replace (XMLNODE *NodeToReplace)
void SetName (const char *name)
void SetNamespace (XMLNAMESPACE *pNameSpace)
void SetProperty (const char *PropName, double value, MISTRING::FLOATFMT floatfmt=MISTRING::FLOATFMT_MaxPrecision)
void SetProperty (const char *PropName, const char *value)
void SetProperty (const char *PropName, const MIUNICODE *value)
void SetText (const char *text)
void SetText (const MIUNICODE *text)
void UnsetProperty (const char *PropName)

Detailed Description

This class is an interface-only class to allow us to treat an xmlNodePtr as a (NODE*) Constructor/CopyConstructor/Destructor all unimplemented Memory allocation done through library calls, not new/delete.


Member Function Documentation

void XMLNODE::AddComment ( const MIUNICODE  ) 

Add a comment to the end of the node.

void XMLNODE::AppendText ( const MIUNICODE text  ) 

Append to the text of a node.

void XMLNODE::Attach ( XMLNODE parent  ) 

Attach this node to an XML document.

This node is first detached from its current location and reattached as the last node of parent. NOTE: You cannot use this function to move a node between documents. To do that, you must first call Copy() to make a copy of the node owned by the destination document and attach the copy.

XMLNODE* XMLNODE::Copy ( bool  recursive = true,
XMLDOC NewDoc = NULL 
) const

Returns a copy of this node.

The caller must either free it or Attach it to a document If the NewDoc parameter is specified (and not NULL) the copy will be owned by that document, but is not actually in its tree anywhere.

void XMLNODE::Delete (  ) 

Unlink a node from its parent and delete it and all its children.

void XMLNODE::DeleteAllChildren (  ) 

Delete all the children of a node but leave the node itself.

void XMLNODE::Detach (  ) 

Remove a node from it's parent tree.

If you Detach it, you must eventually call Delete() on it or reattach it somewhere. The node is still considered part of its source document and when that document is deleted, the node's children will be too.

XMLNODE* XMLNODE::FindChild ( const char *  TagName,
const char *  PropertyName,
const char *  PropertyValue 
) const

Find a child node of a given tag string and a given property.

Parameters:
TagName Must be UTF8
PropertyName Must be UTF8
PropertyValue Must be UTF8
XMLNODE* XMLNODE::FindChild ( const char *  TagName,
const char *  PropertyName,
const MIUNICODE PropertyValue 
) const

Find a child node of a given tag string and a given property.

Parameters:
TagName Must be UTF8
PropertyName Must be UTF8
XMLNODE* XMLNODE::FindChild ( const char *  TagName  )  const

Find a child node of a given tag string.

Parameters:
TagName Must be UTF8
XMLNODE* XMLNODE::FindNext ( const char *  TagName = 0,
const char *  PropName = 0,
const char *  PropValue = 0 
) const

Find next child, matching current or specific tag name and optional property name/value.

Parameters:
TagName Tag name (UTF8), if NULL will use current node tag name
PropName Property name (UTF8), if NULL will match tag name only
PropValue Property value (UTF8), if NULL will not check property value
bool XMLNODE::GetContentXML ( STRUTF8 retstr,
bool  bIncludeSelf,
bool  bFormat = true,
int  indent = 0 
)
Parameters:
retstr The string returned
bIncludeSelf Include the tag for this node if true,
bFormat Format to be more readable if true
indent Initial indenting level (ignored if not bFormat==false)
bool XMLNODE::GetContentXML ( MISTRING retstr,
bool  bIncludeSelf,
bool  bFormat = true,
int  indent = 0 
)
Parameters:
retstr The string returned
bIncludeSelf Include the tag for this node if true,
bFormat Format to be more readable if true
indent Initial indenting level (ignored if not bFormat==false)
XMLNODE* XMLNODE::GetElementByAttribute ( const char *  AttributeName,
const char *  AttributeValue 
) const

Finds a child node which has an attribute with the given value.

This is recursive.

XMLNODE* XMLNODE::GetElementByAttribute ( const char *  AttributeName,
const MIUNICODE AttributeValue 
) const

Finds a child node which has an attribute with the given value.

This is recursive.

bool XMLNODE::GetElementsByTagName ( SIMPLE_ARRAY< XMLNODE * > &  Nodes,
const char *  TagName,
bool  bCaseSensitive = true 
) const

Finds all child nodes of a given tag name (eg: div) This is recursive.

Returns true if any were found, false if not

XMLNODE* XMLNODE::GetFirstChild (  )  const

Return the first child of this node (NULL if no children).

XMLNODE* XMLNODE::GetLastChild (  )  const

Return the last child of this node (NULL if no children).

const char* XMLNODE::GetName (  )  const

Get the name of this node.

Note the name is actually UTF8, but 99.9% of the time is defined by some standards document that requires it to be limited to the ASCII subset

XMLNODE* XMLNODE::GetNext (  )  const

Return the next sibling node (NULL if this is the last node).

XMLNODE* XMLNODE::GetParent (  )  const

Return the parent node of this node (NULL for root node).

XMLNODE* XMLNODE::GetPrevious (  )  const

Return the previous sibling node (NULL if this is the first node).

bool XMLNODE::GetProperty ( const char *  PropName,
UINT64 retvalue,
bool  bCaseSensitive = true 
) const

Get value of a property of this node as UINT64.

Value is left unchanged if the property is not available or can't be converted.

Returns:
true if property exists and can be converted, false if not.
Parameters:
PropName Property name (UTF8)
retvalue Property value returned
bool XMLNODE::GetProperty ( const char *  PropName,
INT64 retvalue,
bool  bCaseSensitive = true 
) const

Get value of a property of this node as INT64.

Value is left unchanged if the property is not available or can't be converted.

Returns:
true if property exists and can be converted, false if not.
Parameters:
PropName Property name (UTF8)
retvalue Property value returned
bool XMLNODE::GetProperty ( const char *  PropName,
UINT32 retvalue,
bool  bCaseSensitive = true 
) const

Get value of a property of this node as UINT32.

Value is left unchanged if the property is not available or can't be converted.

Returns:
true if property exists and can be converted, false if not.
Parameters:
PropName Property name (UTF8)
retvalue Property value returned
bool XMLNODE::GetProperty ( const char *  PropName,
INT32 retvalue,
bool  bCaseSensitive = true 
) const

Get value of a property of this node as INT32.

Value is left unchanged if the property is not available or can't be converted.

Returns:
true if property exists and can be converted, false if not.
Parameters:
PropName Property name (UTF8)
retvalue Property value returned
bool XMLNODE::GetProperty ( const char *  PropName,
double &  retvalue,
bool  bCaseSensitive = true 
) const

Get value of a property of this node as double.

Value is left unchanged if the property is not available or can't be converted.

Returns:
true if property exists and can be converted, false if not.
Parameters:
PropName Property name (UTF8)
retvalue Property value returned
bool XMLNODE::GetProperty ( const char *  PropName,
bool &  retvalue,
bool  bCaseSensitive = true 
) const

Get value of a property of this node as bool.

Value will be true if the named property is "true" or "yes" or "1", false if it's "false", "no" or "0". Value is left unchanged if the property is not available or unrecognized.

Returns:
true if property exists and can be converted, false if not.
Parameters:
PropName Property name (UTF8)
retvalue Property value returned
bool XMLNODE::GetProperty ( const char *  PropName,
STRUTF8 retstr,
bool  bCaseSensitive = true 
) const

Return the value of a property of this node as STRUTF8.

Returned string is left unchanged if the property is not available

Returns:
true if property exists, false if not.
Parameters:
PropName Property name (UTF8)
retstr Property value returned
bool XMLNODE::GetProperty ( const char *  PropName,
MISTRING str,
bool  bCaseSensitive = true 
) const

Return the value of a property of this node as an MISTRING.

Returned string is left unchanged if the property is not available

Returns:
true if property exists, false if not.
Parameters:
PropName Property name (UTF8)
bool XMLNODE::GetPropertyBool ( const char *  PropName,
bool  dft = false,
bool  bCaseSensitive = true 
) const

Return the value of a boolean property of this node.

Returns true if the named property is "true" or "yes", false if it's "false" or "no", and the default if unspecified or none of the above

Parameters:
PropName Property name (UTF8)
double XMLNODE::GetPropertyNum ( const char *  PropName,
double  dft = 0.0,
bool  bCaseSensitive = true 
) const

Return the value of a numeric property of this node.

Parameters:
PropName Property name (UTF8)
bool XMLNODE::GetText ( STRUTF8 str,
bool  bStripLeadingAndTrailingWhitespace = true 
) const

Get node text as STRUTF8.

Returns:
true if text non-empty, false if not.
bool XMLNODE::GetText ( MISTRING str,
bool  bStripLeadingAndTrailingWhitespace = true 
) const

Get node text as MISTRING.

Returns:
true if text non-empty, false if not.
bool XMLNODE::GetValue ( UINT64 retvalue  )  const

Get value of this node's content as UINT64.

Returns:
true if successful, false if not
Parameters:
retvalue Value returned
bool XMLNODE::GetValue ( INT64 retvalue  )  const

Get value of this node's content as INT64.

Returns:
true if successful, false if not
Parameters:
retvalue Value returned
bool XMLNODE::GetValue ( UINT32 retvalue  )  const

Get value of this node's content as UINT32.

Value is left unchanged if content is empty or unrecognized.

Returns:
true if successful, false if not
Parameters:
retvalue Value returned
bool XMLNODE::GetValue ( INT32 retvalue  )  const

Get value of this node's content as INT32.

Value is left unchanged if content is empty or unrecognized.

Returns:
true if successful, false if not
Parameters:
retvalue Value returned
bool XMLNODE::GetValue ( double &  retvalue  )  const

Get value of this node's content as double.

Value is left unchanged if content is empty or unrecognized.

Returns:
true if successful, false if not
Parameters:
retvalue Value returned
bool XMLNODE::GetValue ( bool &  retvalue  )  const

Get value of this node's content as bool.

Value will be true if content is "true" or "yes" or "1", false if it's "false", "no" or "0". Value is left unchanged if content is empty or unrecognized.

Returns:
true if successful, false if not
Parameters:
retvalue Value returned
bool XMLNODE::HasProperty ( const char *  name,
bool  bCaseSensitive = true 
) const

Determine if a node has a given property Note the name is actually UTF8, but 99.9% of the time is defined by some standards document that requires it to be limited to the ASCII subset.

bool XMLNODE::IsCDATA (  )  const

Returns true if this node is a CDATA node.

bool XMLNODE::IsEmpty (  )  const

Returns true if this node is empty.

bool XMLNODE::IsText (  )  const

Returns true if this node is text-only.

XMLNODE* XMLNODE::NewCDATAChild ( const char *  TagName,
const UINT8 value,
int  len = -1,
XMLNAMESPACE pNameSpace = 0 
)

Create a new CDATA node.

A CDATA node can contain any text, except the sequence "]]>" (not counting the quotes) which indicates the end of a CDATA section in XML.

Parameters:
TagName Node tag name (UTF8)
value UTF8
len Length of UTF8 string (-1 to use strlen)
XMLNODE* XMLNODE::NewCDATAChild ( const char *  TagName,
const MIUNICODE value,
XMLNAMESPACE pNameSpace = 0 
)

Create a new CDATA node.

A CDATA node can contain any text, except the sequence "]]>" (not counting the quotes) which indicates the end of a CDATA section in XML. Note that the MIUNICODE version of this method doesn't have a "length" parameter for a reason. The MIUNICODE string will be converted to UTF8, and the only length we're really interested in is the length of the UTF8

Parameters:
TagName Node tag name (UTF8)
XMLNODE* XMLNODE::NewChild ( const XMLNODE NodeToCopy  ) 

Copies a node into this document.

The source node does not have to be from the same document.

XMLNODE* XMLNODE::NewChild ( const char *  TagName,
double  value,
MISTRING::FLOATFMT  floatfmt = MISTRING::FLOATFMT_MaxPrecision,
XMLNAMESPACE pNameSpace = 0 
)

Create a new child node with specified numeric value.

Parameters:
TagName Node tag name (UTF8)
XMLNODE* XMLNODE::NewChild ( const char *  TagName,
const MIUNICODE value,
XMLNAMESPACE pNameSpace = 0 
)

Create a new child node with specified string value.

If any characters in "value" need to be escaped into entity references (eg: &), this method will do it for you.

Parameters:
TagName Node tag name (UTF8)
XMLNODE* XMLNODE::NewChild ( const char *  TagName,
XMLNAMESPACE pNameSpace = 0 
)

Create a new, empty child node.

Parameters:
TagName Node tag name (UTF8)
XMLNODE* XMLNODE::NewTextChild ( const char *  TagName,
const char *  value,
XMLNAMESPACE pNameSpace = 0 
)

Create a new child node containing text If any characters in "value" need to be escaped into entity references (eg: &), this method will do it for you.

This method exists because the xml library claims that xmlNewChild and xmlNewTextChild have some difference. I have yet to figure what that difference actually is.

Parameters:
TagName Node tag name (UTF8)
value Node text (UTF8)
XMLNODE* XMLNODE::NewTextChild ( const char *  TagName,
const MIUNICODE value,
XMLNAMESPACE pNameSpace = 0 
)

Create a new child node containing text If any characters in "value" need to be escaped into entity references (eg: &), this method will do it for you.

This method exists because the xml library claims that xmlNewChild and xmlNewTextChild have some difference. I have yet to figure what that difference actually is.

Parameters:
TagName Node tag name (UTF8)
void XMLNODE::Replace ( XMLNODE NodeToReplace  ) 

Replace a node in an XMLDOC with this node.

The NodeToReplace is removed from its parent and deleted. This node is grafted into the document in its place

void XMLNODE::SetName ( const char *  name  ) 

Set the name of this node.

Note the name is actually UTF8, but 99.9% of the time is defined by some standards document that requires it to be limited to the ASCII subset

void XMLNODE::SetNamespace ( XMLNAMESPACE pNameSpace  ) 

Set the namespace for this node.

void XMLNODE::SetProperty ( const char *  PropName,
double  value,
MISTRING::FLOATFMT  floatfmt = MISTRING::FLOATFMT_MaxPrecision 
)

Set a property on a node using numeric value.

Parameters:
PropName Must be UTF8
void XMLNODE::SetProperty ( const char *  PropName,
const char *  value 
)

Set a property on a node.

Note: The value string may contain single or double quotes, but it is an error for it to contain both.

Parameters:
PropName Must be UTF8
value Must be UTF8
void XMLNODE::SetProperty ( const char *  PropName,
const MIUNICODE value 
)

Set a property on a node.

Note: The value string may contain single or double quotes, but it is an error for it to contain both.

Parameters:
PropName Must be UTF8
void XMLNODE::SetText ( const char *  text  ) 

Set the text of a node (UTF8).

void XMLNODE::SetText ( const MIUNICODE text  ) 

Set the text of a node (MIUNICODE).

void XMLNODE::UnsetProperty ( const char *  PropName  ) 

Unset a property on a node.

Parameters:
PropName Property name (UTF8)

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

Generated on Sun Oct 7 21:34:02 2012 for TNTsdk 2012 by  doxygen 1.6.1