Main Class representing a XML node. More...
#include <xmlParser.h>
Data Structures | |
struct | XMLNodeDataTag |
Public Types | |
enum | XMLCharEncoding { char_encoding_error = 0, char_encoding_UTF8 = 1, char_encoding_legacy = 2, char_encoding_ShiftJIS = 3, char_encoding_GB2312 = 4, char_encoding_Big5 = 5, char_encoding_GBK = 6, char_encoding_error = 0, char_encoding_UTF8 = 1, char_encoding_legacy = 2, char_encoding_ShiftJIS = 3, char_encoding_GB2312 = 4, char_encoding_Big5 = 5, char_encoding_GBK = 6, char_encoding_error = 0, char_encoding_UTF8 = 1, char_encoding_legacy = 2, char_encoding_ShiftJIS = 3, char_encoding_GB2312 = 4, char_encoding_Big5 = 5, char_encoding_GBK = 6 } |
Enumeration for XML character encoding. | |
enum | XMLCharEncoding { char_encoding_error = 0, char_encoding_UTF8 = 1, char_encoding_legacy = 2, char_encoding_ShiftJIS = 3, char_encoding_GB2312 = 4, char_encoding_Big5 = 5, char_encoding_GBK = 6, char_encoding_error = 0, char_encoding_UTF8 = 1, char_encoding_legacy = 2, char_encoding_ShiftJIS = 3, char_encoding_GB2312 = 4, char_encoding_Big5 = 5, char_encoding_GBK = 6, char_encoding_error = 0, char_encoding_UTF8 = 1, char_encoding_legacy = 2, char_encoding_ShiftJIS = 3, char_encoding_GB2312 = 4, char_encoding_Big5 = 5, char_encoding_GBK = 6 } |
Enumeration for XML character encoding. | |
enum | XMLCharEncoding { char_encoding_error = 0, char_encoding_UTF8 = 1, char_encoding_legacy = 2, char_encoding_ShiftJIS = 3, char_encoding_GB2312 = 4, char_encoding_Big5 = 5, char_encoding_GBK = 6, char_encoding_error = 0, char_encoding_UTF8 = 1, char_encoding_legacy = 2, char_encoding_ShiftJIS = 3, char_encoding_GB2312 = 4, char_encoding_Big5 = 5, char_encoding_GBK = 6, char_encoding_error = 0, char_encoding_UTF8 = 1, char_encoding_legacy = 2, char_encoding_ShiftJIS = 3, char_encoding_GB2312 = 4, char_encoding_Big5 = 5, char_encoding_GBK = 6 } |
Enumeration for XML character encoding. | |
typedef enum XMLNode::XMLCharEncoding | XMLCharEncoding |
Enumeration for XML character encoding. | |
typedef enum XMLNode::XMLCharEncoding | XMLCharEncoding |
Enumeration for XML character encoding. | |
typedef enum XMLNode::XMLCharEncoding | XMLCharEncoding |
Enumeration for XML character encoding. | |
Public Member Functions | |
XMLSTR | createXMLString (int nFormat=1, int *pnSize=NULL) const |
Create an XML string starting from the current XMLNode. | |
XMLError | writeToFile (XMLCSTR filename, const char *encoding=NULL, char nFormat=1) const |
Save the content of an xmlNode inside a file. | |
XMLCSTR | getName () const |
name of the node | |
XMLCSTR | getText (int i=0) const |
return ith text field | |
int | nText () const |
nbr of text field | |
XMLNode | getParentNode () const |
return the parent node | |
XMLNode | getChildNode (int i=0) const |
return ith child node | |
XMLNode | getChildNode (XMLCSTR name, int i) const |
return ith child node with specific name (return an empty node if failing). If i==-1, this returns the last XMLNode with the given name. | |
XMLNode | getChildNode (XMLCSTR name, int *i=NULL) const |
return next child node with specific name (return an empty node if failing) | |
XMLNode | getChildNodeWithAttribute (XMLCSTR tagName, XMLCSTR attributeName, XMLCSTR attributeValue=NULL, int *i=NULL) const |
return child node with specific name/attribute (return an empty node if failing) | |
XMLNode | getChildNodeByPath (XMLCSTR path, char createNodeIfMissing=0, XMLCHAR sep='/') |
return the first child node with specific path | |
XMLNode | getChildNodeByPathNonConst (XMLSTR path, char createNodeIfMissing=0, XMLCHAR sep='/') |
return the first child node with specific path. | |
int | nChildNode (XMLCSTR name) const |
return the number of child node with specific name | |
int | nChildNode () const |
nbr of child node | |
XMLAttribute | getAttribute (int i=0) const |
return ith attribute | |
XMLCSTR | getAttributeName (int i=0) const |
return ith attribute name | |
XMLCSTR | getAttributeValue (int i=0) const |
return ith attribute value | |
char | isAttributeSet (XMLCSTR name) const |
test if an attribute with a specific name is given | |
XMLCSTR | getAttribute (XMLCSTR name, int i) const |
return ith attribute content with specific name (return a NULL if failing) | |
XMLCSTR | getAttribute (XMLCSTR name, int *i=NULL) const |
return next attribute content with specific name (return a NULL if failing) | |
int | nAttribute () const |
nbr of attribute | |
XMLClear | getClear (int i=0) const |
return ith clear field (comments) | |
int | nClear () const |
nbr of clear field | |
XMLNodeContents | enumContents (XMLElementPosition i) const |
enumerate all the different contents (attribute,child,text, clear) of the current XMLNode. The order is reflecting the order of the original file/string. NOTE: 0 <= i < nElement(); | |
int | nElement () const |
nbr of different contents for current node | |
char | isEmpty () const |
is this node Empty? | |
char | isDeclaration () const |
is this node a declaration <? .... ?> | |
XMLNode | deepCopy () const |
deep copy (duplicate/clone) a XMLNode | |
XMLNode (const XMLNode &A) | |
to allow shallow/fast copy: | |
XMLNode & | operator= (const XMLNode &A) |
to allow shallow/fast copy: | |
XMLNode | addChild (XMLCSTR lpszName, char isDeclaration=FALSE, XMLElementPosition pos=-1) |
Add a new child node. | |
XMLNode | addChild (XMLNode nodeToAdd, XMLElementPosition pos=-1) |
If the "nodeToAdd" has some parents, it will be detached from it's parents before being attached to the current XMLNode. | |
XMLAttribute * | addAttribute (XMLCSTR lpszName, XMLCSTR lpszValuev) |
Add a new attribute. | |
XMLCSTR | addText (XMLCSTR lpszValue, XMLElementPosition pos=-1) |
Add a new text content. | |
XMLClear * | addClear (XMLCSTR lpszValue, XMLCSTR lpszOpen=NULL, XMLCSTR lpszClose=NULL, XMLElementPosition pos=-1) |
Add a new clear tag. | |
XMLCSTR | updateName (XMLCSTR lpszName) |
change node's name | |
XMLAttribute * | updateAttribute (XMLAttribute *newAttribute, XMLAttribute *oldAttribute) |
if the attribute to update is missing, a new one will be added | |
XMLAttribute * | updateAttribute (XMLCSTR lpszNewValue, XMLCSTR lpszNewName=NULL, int i=0) |
if the attribute to update is missing, a new one will be added | |
XMLAttribute * | updateAttribute (XMLCSTR lpszNewValue, XMLCSTR lpszNewName, XMLCSTR lpszOldName) |
set lpszNewName=NULL if you don't want to change the name of the attribute if the attribute to update is missing, a new one will be added | |
XMLCSTR | updateText (XMLCSTR lpszNewValue, int i=0) |
if the text to update is missing, a new one will be added | |
XMLCSTR | updateText (XMLCSTR lpszNewValue, XMLCSTR lpszOldValue) |
if the text to update is missing, a new one will be added | |
XMLClear * | updateClear (XMLCSTR lpszNewContent, int i=0) |
if the clearTag to update is missing, a new one will be added | |
XMLClear * | updateClear (XMLClear *newP, XMLClear *oldP) |
if the clearTag to update is missing, a new one will be added | |
XMLClear * | updateClear (XMLCSTR lpszNewValue, XMLCSTR lpszOldValue) |
if the clearTag to update is missing, a new one will be added | |
void | deleteNodeContent () |
The "deleteNodeContent" function forces the deletion of the content of this XMLNode and the subtree. | |
void | deleteAttribute (int i=0) |
Delete the ith attribute of the current XMLNode. | |
void | deleteAttribute (XMLCSTR lpszName) |
Delete the attribute with the given name (the "strcmp" function is used to find the right attribute). | |
void | deleteAttribute (XMLAttribute *anAttribute) |
Delete the attribute with the name "anAttribute->lpszName" (the "strcmp" function is used to find the right attribute). | |
void | deleteText (int i=0) |
Delete the Ith text content of the current XMLNode. | |
void | deleteText (XMLCSTR lpszValue) |
Delete the text content "lpszValue" inside the current XMLNode (direct "pointer-to-pointer" comparison is used to find the right text). | |
void | deleteClear (int i=0) |
Delete the Ith clear tag inside the current XMLNode. | |
void | deleteClear (XMLCSTR lpszValue) |
Delete the clear tag "lpszValue" inside the current XMLNode (direct "pointer-to-pointer" comparison is used to find the clear tag). | |
void | deleteClear (XMLClear *p) |
Delete the clear tag "p" inside the current XMLNode (direct "pointer-to-pointer" comparison on the lpszName of the clear tag is used to find the clear tag). | |
XMLNode | addChild_WOSD (XMLSTR lpszName, char isDeclaration=FALSE, XMLElementPosition pos=-1) |
Add a new child node. | |
XMLAttribute * | addAttribute_WOSD (XMLSTR lpszName, XMLSTR lpszValue) |
Add a new attribute. | |
XMLCSTR | addText_WOSD (XMLSTR lpszValue, XMLElementPosition pos=-1) |
Add a new text content. | |
XMLClear * | addClear_WOSD (XMLSTR lpszValue, XMLCSTR lpszOpen=NULL, XMLCSTR lpszClose=NULL, XMLElementPosition pos=-1) |
Add a new clear Tag. | |
XMLCSTR | updateName_WOSD (XMLSTR lpszName) |
change node's name | |
XMLAttribute * | updateAttribute_WOSD (XMLAttribute *newAttribute, XMLAttribute *oldAttribute) |
if the attribute to update is missing, a new one will be added | |
XMLAttribute * | updateAttribute_WOSD (XMLSTR lpszNewValue, XMLSTR lpszNewName=NULL, int i=0) |
if the attribute to update is missing, a new one will be added | |
XMLAttribute * | updateAttribute_WOSD (XMLSTR lpszNewValue, XMLSTR lpszNewName, XMLCSTR lpszOldName) |
set lpszNewName=NULL if you don't want to change the name of the attribute if the attribute to update is missing, a new one will be added | |
XMLCSTR | updateText_WOSD (XMLSTR lpszNewValue, int i=0) |
if the text to update is missing, a new one will be added | |
XMLCSTR | updateText_WOSD (XMLSTR lpszNewValue, XMLCSTR lpszOldValue) |
if the text to update is missing, a new one will be added | |
XMLClear * | updateClear_WOSD (XMLSTR lpszNewContent, int i=0) |
if the clearTag to update is missing, a new one will be added | |
XMLClear * | updateClear_WOSD (XMLClear *newP, XMLClear *oldP) |
if the clearTag to update is missing, a new one will be added | |
XMLClear * | updateClear_WOSD (XMLSTR lpszNewValue, XMLCSTR lpszOldValue) |
if the clearTag to update is missing, a new one will be added | |
XMLElementPosition | positionOfText (int i=0) const |
XMLElementPosition | positionOfText (XMLCSTR lpszValue) const |
XMLElementPosition | positionOfClear (int i=0) const |
XMLElementPosition | positionOfClear (XMLCSTR lpszValue) const |
XMLElementPosition | positionOfClear (XMLClear *a) const |
XMLElementPosition | positionOfChildNode (int i=0) const |
XMLElementPosition | positionOfChildNode (XMLNode x) const |
XMLElementPosition | positionOfChildNode (XMLCSTR name, int i=0) const |
return the position of the ith childNode with the specified name if (name==NULL) return the position of the ith childNode | |
XMLSTR | createXMLString (int nFormat=1, int *pnSize=NULL) const |
Create an XML string starting from the current XMLNode. | |
XMLError | writeToFile (XMLCSTR filename, const char *encoding=NULL, char nFormat=1) const |
Save the content of an xmlNode inside a file. | |
XMLCSTR | getName () const |
name of the node | |
XMLCSTR | getText (int i=0) const |
return ith text field | |
int | nText () const |
nbr of text field | |
XMLNode | getParentNode () const |
return the parent node | |
XMLNode | getChildNode (int i=0) const |
return ith child node | |
XMLNode | getChildNode (XMLCSTR name, int i) const |
return ith child node with specific name (return an empty node if failing). If i==-1, this returns the last XMLNode with the given name. | |
XMLNode | getChildNode (XMLCSTR name, int *i=NULL) const |
return next child node with specific name (return an empty node if failing) | |
XMLNode | getChildNodeWithAttribute (XMLCSTR tagName, XMLCSTR attributeName, XMLCSTR attributeValue=NULL, int *i=NULL) const |
return child node with specific name/attribute (return an empty node if failing) | |
XMLNode | getChildNodeByPath (XMLCSTR path, char createNodeIfMissing=0, XMLCHAR sep='/') |
return the first child node with specific path | |
XMLNode | getChildNodeByPathNonConst (XMLSTR path, char createNodeIfMissing=0, XMLCHAR sep='/') |
return the first child node with specific path. | |
int | nChildNode (XMLCSTR name) const |
return the number of child node with specific name | |
int | nChildNode () const |
nbr of child node | |
XMLAttribute | getAttribute (int i=0) const |
return ith attribute | |
XMLCSTR | getAttributeName (int i=0) const |
return ith attribute name | |
XMLCSTR | getAttributeValue (int i=0) const |
return ith attribute value | |
char | isAttributeSet (XMLCSTR name) const |
test if an attribute with a specific name is given | |
XMLCSTR | getAttribute (XMLCSTR name, int i) const |
return ith attribute content with specific name (return a NULL if failing) | |
XMLCSTR | getAttribute (XMLCSTR name, int *i=NULL) const |
return next attribute content with specific name (return a NULL if failing) | |
int | nAttribute () const |
nbr of attribute | |
XMLClear | getClear (int i=0) const |
return ith clear field (comments) | |
int | nClear () const |
nbr of clear field | |
XMLNodeContents | enumContents (XMLElementPosition i) const |
enumerate all the different contents (attribute,child,text, clear) of the current XMLNode. The order is reflecting the order of the original file/string. NOTE: 0 <= i < nElement(); | |
int | nElement () const |
nbr of different contents for current node | |
char | isEmpty () const |
is this node Empty? | |
char | isDeclaration () const |
is this node a declaration <? .... ?> | |
XMLNode | deepCopy () const |
deep copy (duplicate/clone) a XMLNode | |
XMLNode (const XMLNode &A) | |
to allow shallow/fast copy: | |
XMLNode & | operator= (const XMLNode &A) |
to allow shallow/fast copy: | |
XMLNode | addChild (XMLCSTR lpszName, char isDeclaration=FALSE, XMLElementPosition pos=-1) |
Add a new child node. | |
XMLNode | addChild (XMLNode nodeToAdd, XMLElementPosition pos=-1) |
If the "nodeToAdd" has some parents, it will be detached from it's parents before being attached to the current XMLNode. | |
XMLAttribute * | addAttribute (XMLCSTR lpszName, XMLCSTR lpszValuev) |
Add a new attribute. | |
XMLCSTR | addText (XMLCSTR lpszValue, XMLElementPosition pos=-1) |
Add a new text content. | |
XMLClear * | addClear (XMLCSTR lpszValue, XMLCSTR lpszOpen=NULL, XMLCSTR lpszClose=NULL, XMLElementPosition pos=-1) |
Add a new clear tag. | |
XMLCSTR | updateName (XMLCSTR lpszName) |
change node's name | |
XMLAttribute * | updateAttribute (XMLAttribute *newAttribute, XMLAttribute *oldAttribute) |
if the attribute to update is missing, a new one will be added | |
XMLAttribute * | updateAttribute (XMLCSTR lpszNewValue, XMLCSTR lpszNewName=NULL, int i=0) |
if the attribute to update is missing, a new one will be added | |
XMLAttribute * | updateAttribute (XMLCSTR lpszNewValue, XMLCSTR lpszNewName, XMLCSTR lpszOldName) |
set lpszNewName=NULL if you don't want to change the name of the attribute if the attribute to update is missing, a new one will be added | |
XMLCSTR | updateText (XMLCSTR lpszNewValue, int i=0) |
if the text to update is missing, a new one will be added | |
XMLCSTR | updateText (XMLCSTR lpszNewValue, XMLCSTR lpszOldValue) |
if the text to update is missing, a new one will be added | |
XMLClear * | updateClear (XMLCSTR lpszNewContent, int i=0) |
if the clearTag to update is missing, a new one will be added | |
XMLClear * | updateClear (XMLClear *newP, XMLClear *oldP) |
if the clearTag to update is missing, a new one will be added | |
XMLClear * | updateClear (XMLCSTR lpszNewValue, XMLCSTR lpszOldValue) |
if the clearTag to update is missing, a new one will be added | |
void | deleteNodeContent () |
The "deleteNodeContent" function forces the deletion of the content of this XMLNode and the subtree. | |
void | deleteAttribute (int i=0) |
Delete the ith attribute of the current XMLNode. | |
void | deleteAttribute (XMLCSTR lpszName) |
Delete the attribute with the given name (the "strcmp" function is used to find the right attribute). | |
void | deleteAttribute (XMLAttribute *anAttribute) |
Delete the attribute with the name "anAttribute->lpszName" (the "strcmp" function is used to find the right attribute). | |
void | deleteText (int i=0) |
Delete the Ith text content of the current XMLNode. | |
void | deleteText (XMLCSTR lpszValue) |
Delete the text content "lpszValue" inside the current XMLNode (direct "pointer-to-pointer" comparison is used to find the right text). | |
void | deleteClear (int i=0) |
Delete the Ith clear tag inside the current XMLNode. | |
void | deleteClear (XMLCSTR lpszValue) |
Delete the clear tag "lpszValue" inside the current XMLNode (direct "pointer-to-pointer" comparison is used to find the clear tag). | |
void | deleteClear (XMLClear *p) |
Delete the clear tag "p" inside the current XMLNode (direct "pointer-to-pointer" comparison on the lpszName of the clear tag is used to find the clear tag). | |
XMLNode | addChild_WOSD (XMLSTR lpszName, char isDeclaration=FALSE, XMLElementPosition pos=-1) |
Add a new child node. | |
XMLAttribute * | addAttribute_WOSD (XMLSTR lpszName, XMLSTR lpszValue) |
Add a new attribute. | |
XMLCSTR | addText_WOSD (XMLSTR lpszValue, XMLElementPosition pos=-1) |
Add a new text content. | |
XMLClear * | addClear_WOSD (XMLSTR lpszValue, XMLCSTR lpszOpen=NULL, XMLCSTR lpszClose=NULL, XMLElementPosition pos=-1) |
Add a new clear Tag. | |
XMLCSTR | updateName_WOSD (XMLSTR lpszName) |
change node's name | |
XMLAttribute * | updateAttribute_WOSD (XMLAttribute *newAttribute, XMLAttribute *oldAttribute) |
if the attribute to update is missing, a new one will be added | |
XMLAttribute * | updateAttribute_WOSD (XMLSTR lpszNewValue, XMLSTR lpszNewName=NULL, int i=0) |
if the attribute to update is missing, a new one will be added | |
XMLAttribute * | updateAttribute_WOSD (XMLSTR lpszNewValue, XMLSTR lpszNewName, XMLCSTR lpszOldName) |
set lpszNewName=NULL if you don't want to change the name of the attribute if the attribute to update is missing, a new one will be added | |
XMLCSTR | updateText_WOSD (XMLSTR lpszNewValue, int i=0) |
if the text to update is missing, a new one will be added | |
XMLCSTR | updateText_WOSD (XMLSTR lpszNewValue, XMLCSTR lpszOldValue) |
if the text to update is missing, a new one will be added | |
XMLClear * | updateClear_WOSD (XMLSTR lpszNewContent, int i=0) |
if the clearTag to update is missing, a new one will be added | |
XMLClear * | updateClear_WOSD (XMLClear *newP, XMLClear *oldP) |
if the clearTag to update is missing, a new one will be added | |
XMLClear * | updateClear_WOSD (XMLSTR lpszNewValue, XMLCSTR lpszOldValue) |
if the clearTag to update is missing, a new one will be added | |
XMLElementPosition | positionOfText (int i=0) const |
XMLElementPosition | positionOfText (XMLCSTR lpszValue) const |
XMLElementPosition | positionOfClear (int i=0) const |
XMLElementPosition | positionOfClear (XMLCSTR lpszValue) const |
XMLElementPosition | positionOfClear (XMLClear *a) const |
XMLElementPosition | positionOfChildNode (int i=0) const |
XMLElementPosition | positionOfChildNode (XMLNode x) const |
XMLElementPosition | positionOfChildNode (XMLCSTR name, int i=0) const |
return the position of the ith childNode with the specified name if (name==NULL) return the position of the ith childNode | |
XMLSTR | createXMLString (int nFormat=1, int *pnSize=NULL) const |
Create an XML string starting from the current XMLNode. | |
XMLError | writeToFile (XMLCSTR filename, const char *encoding=NULL, char nFormat=1) const |
Save the content of an xmlNode inside a file. | |
XMLCSTR | getName () const |
name of the node | |
XMLCSTR | getText (int i=0) const |
return ith text field | |
int | nText () const |
nbr of text field | |
XMLNode | getParentNode () const |
return the parent node | |
XMLNode | getChildNode (int i=0) const |
return ith child node | |
XMLNode | getChildNode (XMLCSTR name, int i) const |
return ith child node with specific name (return an empty node if failing). If i==-1, this returns the last XMLNode with the given name. | |
XMLNode | getChildNode (XMLCSTR name, int *i=NULL) const |
return next child node with specific name (return an empty node if failing) | |
XMLNode | getChildNodeWithAttribute (XMLCSTR tagName, XMLCSTR attributeName, XMLCSTR attributeValue=NULL, int *i=NULL) const |
return child node with specific name/attribute (return an empty node if failing) | |
XMLNode | getChildNodeByPath (XMLCSTR path, char createNodeIfMissing=0, XMLCHAR sep='/') |
return the first child node with specific path | |
XMLNode | getChildNodeByPathNonConst (XMLSTR path, char createNodeIfMissing=0, XMLCHAR sep='/') |
return the first child node with specific path. | |
int | nChildNode (XMLCSTR name) const |
return the number of child node with specific name | |
int | nChildNode () const |
nbr of child node | |
XMLAttribute | getAttribute (int i=0) const |
return ith attribute | |
XMLCSTR | getAttributeName (int i=0) const |
return ith attribute name | |
XMLCSTR | getAttributeValue (int i=0) const |
return ith attribute value | |
char | isAttributeSet (XMLCSTR name) const |
test if an attribute with a specific name is given | |
XMLCSTR | getAttribute (XMLCSTR name, int i) const |
return ith attribute content with specific name (return a NULL if failing) | |
XMLCSTR | getAttribute (XMLCSTR name, int *i=NULL) const |
return next attribute content with specific name (return a NULL if failing) | |
int | nAttribute () const |
nbr of attribute | |
XMLClear | getClear (int i=0) const |
return ith clear field (comments) | |
int | nClear () const |
nbr of clear field | |
XMLNodeContents | enumContents (XMLElementPosition i) const |
enumerate all the different contents (attribute,child,text, clear) of the current XMLNode. The order is reflecting the order of the original file/string. NOTE: 0 <= i < nElement(); | |
int | nElement () const |
nbr of different contents for current node | |
char | isEmpty () const |
is this node Empty? | |
char | isDeclaration () const |
is this node a declaration <? .... ?> | |
XMLNode | deepCopy () const |
deep copy (duplicate/clone) a XMLNode | |
XMLNode (const XMLNode &A) | |
to allow shallow/fast copy: | |
XMLNode & | operator= (const XMLNode &A) |
to allow shallow/fast copy: | |
XMLNode | addChild (XMLCSTR lpszName, char isDeclaration=FALSE, XMLElementPosition pos=-1) |
Add a new child node. | |
XMLNode | addChild (XMLNode nodeToAdd, XMLElementPosition pos=-1) |
If the "nodeToAdd" has some parents, it will be detached from it's parents before being attached to the current XMLNode. | |
XMLAttribute * | addAttribute (XMLCSTR lpszName, XMLCSTR lpszValuev) |
Add a new attribute. | |
XMLCSTR | addText (XMLCSTR lpszValue, XMLElementPosition pos=-1) |
Add a new text content. | |
XMLClear * | addClear (XMLCSTR lpszValue, XMLCSTR lpszOpen=NULL, XMLCSTR lpszClose=NULL, XMLElementPosition pos=-1) |
Add a new clear tag. | |
XMLCSTR | updateName (XMLCSTR lpszName) |
change node's name | |
XMLAttribute * | updateAttribute (XMLAttribute *newAttribute, XMLAttribute *oldAttribute) |
if the attribute to update is missing, a new one will be added | |
XMLAttribute * | updateAttribute (XMLCSTR lpszNewValue, XMLCSTR lpszNewName=NULL, int i=0) |
if the attribute to update is missing, a new one will be added | |
XMLAttribute * | updateAttribute (XMLCSTR lpszNewValue, XMLCSTR lpszNewName, XMLCSTR lpszOldName) |
set lpszNewName=NULL if you don't want to change the name of the attribute if the attribute to update is missing, a new one will be added | |
XMLCSTR | updateText (XMLCSTR lpszNewValue, int i=0) |
if the text to update is missing, a new one will be added | |
XMLCSTR | updateText (XMLCSTR lpszNewValue, XMLCSTR lpszOldValue) |
if the text to update is missing, a new one will be added | |
XMLClear * | updateClear (XMLCSTR lpszNewContent, int i=0) |
if the clearTag to update is missing, a new one will be added | |
XMLClear * | updateClear (XMLClear *newP, XMLClear *oldP) |
if the clearTag to update is missing, a new one will be added | |
XMLClear * | updateClear (XMLCSTR lpszNewValue, XMLCSTR lpszOldValue) |
if the clearTag to update is missing, a new one will be added | |
void | deleteNodeContent () |
The "deleteNodeContent" function forces the deletion of the content of this XMLNode and the subtree. | |
void | deleteAttribute (int i=0) |
Delete the ith attribute of the current XMLNode. | |
void | deleteAttribute (XMLCSTR lpszName) |
Delete the attribute with the given name (the "strcmp" function is used to find the right attribute). | |
void | deleteAttribute (XMLAttribute *anAttribute) |
Delete the attribute with the name "anAttribute->lpszName" (the "strcmp" function is used to find the right attribute). | |
void | deleteText (int i=0) |
Delete the Ith text content of the current XMLNode. | |
void | deleteText (XMLCSTR lpszValue) |
Delete the text content "lpszValue" inside the current XMLNode (direct "pointer-to-pointer" comparison is used to find the right text). | |
void | deleteClear (int i=0) |
Delete the Ith clear tag inside the current XMLNode. | |
void | deleteClear (XMLCSTR lpszValue) |
Delete the clear tag "lpszValue" inside the current XMLNode (direct "pointer-to-pointer" comparison is used to find the clear tag). | |
void | deleteClear (XMLClear *p) |
Delete the clear tag "p" inside the current XMLNode (direct "pointer-to-pointer" comparison on the lpszName of the clear tag is used to find the clear tag). | |
XMLNode | addChild_WOSD (XMLSTR lpszName, char isDeclaration=FALSE, XMLElementPosition pos=-1) |
Add a new child node. | |
XMLAttribute * | addAttribute_WOSD (XMLSTR lpszName, XMLSTR lpszValue) |
Add a new attribute. | |
XMLCSTR | addText_WOSD (XMLSTR lpszValue, XMLElementPosition pos=-1) |
Add a new text content. | |
XMLClear * | addClear_WOSD (XMLSTR lpszValue, XMLCSTR lpszOpen=NULL, XMLCSTR lpszClose=NULL, XMLElementPosition pos=-1) |
Add a new clear Tag. | |
XMLCSTR | updateName_WOSD (XMLSTR lpszName) |
change node's name | |
XMLAttribute * | updateAttribute_WOSD (XMLAttribute *newAttribute, XMLAttribute *oldAttribute) |
if the attribute to update is missing, a new one will be added | |
XMLAttribute * | updateAttribute_WOSD (XMLSTR lpszNewValue, XMLSTR lpszNewName=NULL, int i=0) |
if the attribute to update is missing, a new one will be added | |
XMLAttribute * | updateAttribute_WOSD (XMLSTR lpszNewValue, XMLSTR lpszNewName, XMLCSTR lpszOldName) |
set lpszNewName=NULL if you don't want to change the name of the attribute if the attribute to update is missing, a new one will be added | |
XMLCSTR | updateText_WOSD (XMLSTR lpszNewValue, int i=0) |
if the text to update is missing, a new one will be added | |
XMLCSTR | updateText_WOSD (XMLSTR lpszNewValue, XMLCSTR lpszOldValue) |
if the text to update is missing, a new one will be added | |
XMLClear * | updateClear_WOSD (XMLSTR lpszNewContent, int i=0) |
if the clearTag to update is missing, a new one will be added | |
XMLClear * | updateClear_WOSD (XMLClear *newP, XMLClear *oldP) |
if the clearTag to update is missing, a new one will be added | |
XMLClear * | updateClear_WOSD (XMLSTR lpszNewValue, XMLCSTR lpszOldValue) |
if the clearTag to update is missing, a new one will be added | |
XMLElementPosition | positionOfText (int i=0) const |
XMLElementPosition | positionOfText (XMLCSTR lpszValue) const |
XMLElementPosition | positionOfClear (int i=0) const |
XMLElementPosition | positionOfClear (XMLCSTR lpszValue) const |
XMLElementPosition | positionOfClear (XMLClear *a) const |
XMLElementPosition | positionOfChildNode (int i=0) const |
XMLElementPosition | positionOfChildNode (XMLNode x) const |
XMLElementPosition | positionOfChildNode (XMLCSTR name, int i=0) const |
return the position of the ith childNode with the specified name if (name==NULL) return the position of the ith childNode | |
Static Public Member Functions | |
static XMLCSTR | getVersion () |
Return the XMLParser library version number. | |
static XMLNode | parseString (XMLCSTR lpXMLString, XMLCSTR tag=NULL, XMLResults *pResults=NULL) |
Parse an XML string and return the root of a XMLNode tree representing the string. | |
static XMLNode | parseFile (XMLCSTR filename, XMLCSTR tag=NULL, XMLResults *pResults=NULL) |
Parse an XML file and return the root of a XMLNode tree representing the file. | |
static XMLNode | openFileHelper (XMLCSTR filename, XMLCSTR tag=NULL) |
Parse an XML file and return the root of a XMLNode tree representing the file. A very crude error checking is made. An attempt to guess the Char Encoding used in the file is made. | |
static XMLCSTR | getError (XMLError error) |
this gives you a user-friendly explanation of the parsing error | |
static XMLNode | emptyNode () |
return XMLNode::emptyXMLNode; | |
static XMLNode | createXMLTopNode (XMLCSTR lpszName, char isDeclaration=FALSE) |
Create the top node of an XMLNode structure. | |
static XMLNode | createXMLTopNode_WOSD (XMLSTR lpszName, char isDeclaration=FALSE) |
Create the top node of an XMLNode structure. | |
static char | setGlobalOptions (XMLCharEncoding characterEncoding=XMLNode::char_encoding_UTF8, char guessWideCharChars=1, char dropWhiteSpace=1, char removeCommentsInMiddleOfText=1) |
Sets the global options for the conversions. | |
static XMLCharEncoding | guessCharEncoding (void *buffer, int bufLen, char useXMLEncodingAttribute=1) |
Guess the character encoding of the string (ascii, utf8 or shift-JIS). | |
static XMLCSTR | getVersion () |
Return the XMLParser library version number. | |
static XMLNode | parseString (XMLCSTR lpXMLString, XMLCSTR tag=NULL, XMLResults *pResults=NULL) |
Parse an XML string and return the root of a XMLNode tree representing the string. | |
static XMLNode | parseFile (XMLCSTR filename, XMLCSTR tag=NULL, XMLResults *pResults=NULL) |
Parse an XML file and return the root of a XMLNode tree representing the file. | |
static XMLNode | openFileHelper (XMLCSTR filename, XMLCSTR tag=NULL) |
Parse an XML file and return the root of a XMLNode tree representing the file. A very crude error checking is made. An attempt to guess the Char Encoding used in the file is made. | |
static XMLCSTR | getError (XMLError error) |
this gives you a user-friendly explanation of the parsing error | |
static XMLNode | emptyNode () |
return XMLNode::emptyXMLNode; | |
static XMLNode | createXMLTopNode (XMLCSTR lpszName, char isDeclaration=FALSE) |
Create the top node of an XMLNode structure. | |
static XMLNode | createXMLTopNode_WOSD (XMLSTR lpszName, char isDeclaration=FALSE) |
Create the top node of an XMLNode structure. | |
static char | setGlobalOptions (XMLCharEncoding characterEncoding=XMLNode::char_encoding_UTF8, char guessWideCharChars=1, char dropWhiteSpace=1, char removeCommentsInMiddleOfText=1) |
Sets the global options for the conversions. | |
static XMLCharEncoding | guessCharEncoding (void *buffer, int bufLen, char useXMLEncodingAttribute=1) |
Guess the character encoding of the string (ascii, utf8 or shift-JIS). | |
static XMLCSTR | getVersion () |
Return the XMLParser library version number. | |
static XMLNode | parseString (XMLCSTR lpXMLString, XMLCSTR tag=NULL, XMLResults *pResults=NULL) |
Parse an XML string and return the root of a XMLNode tree representing the string. | |
static XMLNode | parseFile (XMLCSTR filename, XMLCSTR tag=NULL, XMLResults *pResults=NULL) |
Parse an XML file and return the root of a XMLNode tree representing the file. | |
static XMLNode | openFileHelper (XMLCSTR filename, XMLCSTR tag=NULL) |
Parse an XML file and return the root of a XMLNode tree representing the file. A very crude error checking is made. An attempt to guess the Char Encoding used in the file is made. | |
static XMLCSTR | getError (XMLError error) |
this gives you a user-friendly explanation of the parsing error | |
static XMLNode | emptyNode () |
return XMLNode::emptyXMLNode; | |
static XMLNode | createXMLTopNode (XMLCSTR lpszName, char isDeclaration=FALSE) |
Create the top node of an XMLNode structure. | |
static XMLNode | createXMLTopNode_WOSD (XMLSTR lpszName, char isDeclaration=FALSE) |
Create the top node of an XMLNode structure. | |
static char | setGlobalOptions (XMLCharEncoding characterEncoding=XMLNode::char_encoding_UTF8, char guessWideCharChars=1, char dropWhiteSpace=1, char removeCommentsInMiddleOfText=1) |
Sets the global options for the conversions. | |
static XMLCharEncoding | guessCharEncoding (void *buffer, int bufLen, char useXMLEncodingAttribute=1) |
Guess the character encoding of the string (ascii, utf8 or shift-JIS). | |
Static Public Attributes | |
static XMLNode | emptyXMLNode |
static XMLClear | emptyXMLClear = { NULL, NULL, NULL} |
static XMLAttribute | emptyXMLAttribute = { NULL, NULL} |
Main Class representing a XML node.
All operations are performed using this class.
XMLClear* XMLNode::addClear | ( | XMLCSTR | lpszValue, | |
XMLCSTR | lpszOpen = NULL , |
|||
XMLCSTR | lpszClose = NULL , |
|||
XMLElementPosition | pos = -1 | |||
) |
Add a new clear tag.
lpszOpen | default value "<![CDATA[" | |
lpszClose | default value "]]>" |
XMLClear* XMLNode::addClear | ( | XMLCSTR | lpszValue, | |
XMLCSTR | lpszOpen = NULL , |
|||
XMLCSTR | lpszClose = NULL , |
|||
XMLElementPosition | pos = -1 | |||
) |
Add a new clear tag.
lpszOpen | default value "<![CDATA[" | |
lpszClose | default value "]]>" |
XMLSTR XMLNode::createXMLString | ( | int | nFormat = 1 , |
|
int * | pnSize = NULL | |||
) | const |
Create an XML string starting from the current XMLNode.
The returned string should be free'd using the "freeXMLString" function.
If nFormat==0, no formatting is required otherwise this returns an user friendly XML string from a given element with appropriate white spaces and carriage returns. if pnSize is given it returns the size in character of the string.
XMLSTR XMLNode::createXMLString | ( | int | nFormat = 1 , |
|
int * | pnSize = NULL | |||
) | const |
Create an XML string starting from the current XMLNode.
The returned string should be free'd using the "freeXMLString" function.
If nFormat==0, no formatting is required otherwise this returns an user friendly XML string from a given element with appropriate white spaces and carriage returns. if pnSize is given it returns the size in character of the string.
void XMLNode::deleteNodeContent | ( | ) |
void XMLNode::deleteNodeContent | ( | ) |
XMLCSTR XMLNode::getVersion | ( | ) | [static] |
Return the XMLParser library version number.
XML.c - implementation file for basic XML parser written in ANSI C++ for portability. It works by using recursion and a node tree for breaking down the elements of an XML document.
NOTE:
If you add "#define STRICT_PARSING", on the first line of this file the parser will see the following XML-stream: some textother text as an error. Otherwise, this tring will be equivalent to: some textother text
NOTE:
If you add "#define APPROXIMATE_PARSING" on the first line of this file the parser will see the following XML-stream: <data name="n1"> <data name="n2"> <data name="n3"> as equivalent to the following XML-stream: <data name="n1"> <data name="n2"> <data name="n3"> This can be useful for badly-formed XML-streams but prevent the use of the following XML-stream (problem is: tags at contiguous levels have the same names): <data name="n1"> <data name="n2"> <data name="n3"> </data> </data>
NOTE:
If you add "#define _XMLPARSER_NO_MESSAGEBOX_" on the first line of this file the "openFileHelper" function will always display error messages inside the console instead of inside a message-box-window. Message-box-windows are available on windows 9x/NT/2000/XP/Vista only.
The following license terms for the "XMLParser library from Business-Insight" apply to projects that are in some way related to the "mcpat project", including applications using "mcpat project" and tools developed for enhancing "mcpat project". All other projects (not related to "mcpat project") have to use the "XMLParser library from Business-Insight" code under the Aladdin Free Public License (AFPL) See the file "AFPL-license.txt" for more informations about the AFPL license. (see http://www.artifex.com/downloads/doc/Public.htm for detailed AFPL terms)
Redistribution and use of the "XMLParser library from Business-Insight" in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Frank Vanden Berghen nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY Business-Insight ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Business-Insight BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Copyright (c) 2002, Business-Insight Business-Insight All rights reserved.
static XMLCharEncoding XMLNode::guessCharEncoding | ( | void * | buffer, | |
int | bufLen, | |||
char | useXMLEncodingAttribute = 1 | |||
) | [static] |
Guess the character encoding of the string (ascii, utf8 or shift-JIS).
The "guessCharEncoding" function try to guess the character encoding. You most-probably will never have to use this function. It then returns the appropriate value of the global parameter "characterEncoding" described in the XMLNode::setGlobalOptions. The guess is based on the content of a buffer of length "bufLen" bytes that contains the first bytes (minimum 25 bytes; 200 bytes is a good value) of the file to be parsed. The XMLNode::openFileHelper function is using this function to automatically compute the value of the "characterEncoding" global parameter. There are several heuristics used to do the guess. One of the heuristic is based on the "encoding" attribute. The original XML specifications forbids to use this attribute to do the guess but you can still use it if you set "useXMLEncodingAttribute" to 1 (this is the default behavior and the behavior of most parsers). If an inconsistency in the encoding is detected, then the return value is "0".
static XMLCharEncoding XMLNode::guessCharEncoding | ( | void * | buffer, | |
int | bufLen, | |||
char | useXMLEncodingAttribute = 1 | |||
) | [static] |
Guess the character encoding of the string (ascii, utf8 or shift-JIS).
The "guessCharEncoding" function try to guess the character encoding. You most-probably will never have to use this function. It then returns the appropriate value of the global parameter "characterEncoding" described in the XMLNode::setGlobalOptions. The guess is based on the content of a buffer of length "bufLen" bytes that contains the first bytes (minimum 25 bytes; 200 bytes is a good value) of the file to be parsed. The XMLNode::openFileHelper function is using this function to automatically compute the value of the "characterEncoding" global parameter. There are several heuristics used to do the guess. One of the heuristic is based on the "encoding" attribute. The original XML specifications forbids to use this attribute to do the guess but you can still use it if you set "useXMLEncodingAttribute" to 1 (this is the default behavior and the behavior of most parsers). If an inconsistency in the encoding is detected, then the return value is "0".
static XMLNode XMLNode::openFileHelper | ( | XMLCSTR | filename, | |
XMLCSTR | tag = NULL | |||
) | [static] |
Parse an XML file and return the root of a XMLNode tree representing the file. A very crude error checking is made. An attempt to guess the Char Encoding used in the file is made.
The "openFileHelper" function reports to the screen all the warnings and errors that occurred during parsing of the XML file. This function also tries to guess char Encoding (UTF-8, ASCII or SHIT-JIS) based on the first 200 bytes of the file. Since each application has its own way to report and deal with errors, you should rather use the "parseFile" function to parse XML files and program yourself thereafter an "error reporting" tailored for your needs (instead of using the very crude "error reporting" mechanism included inside the "openFileHelper" function).
If the XML document is corrupted, the "openFileHelper" method will:
I strongly suggest that you write your own "openFileHelper" method tailored to your needs. If you still want to parse the file, you can use the APPROXIMATE_PARSING option as explained inside the note at the beginning of the "xmlParser.cpp" file.
static XMLNode XMLNode::openFileHelper | ( | XMLCSTR | filename, | |
XMLCSTR | tag = NULL | |||
) | [static] |
Parse an XML file and return the root of a XMLNode tree representing the file. A very crude error checking is made. An attempt to guess the Char Encoding used in the file is made.
The "openFileHelper" function reports to the screen all the warnings and errors that occurred during parsing of the XML file. This function also tries to guess char Encoding (UTF-8, ASCII or SHIT-JIS) based on the first 200 bytes of the file. Since each application has its own way to report and deal with errors, you should rather use the "parseFile" function to parse XML files and program yourself thereafter an "error reporting" tailored for your needs (instead of using the very crude "error reporting" mechanism included inside the "openFileHelper" function).
If the XML document is corrupted, the "openFileHelper" method will:
I strongly suggest that you write your own "openFileHelper" method tailored to your needs. If you still want to parse the file, you can use the APPROXIMATE_PARSING option as explained inside the note at the beginning of the "xmlParser.cpp" file.
static XMLNode XMLNode::parseFile | ( | XMLCSTR | filename, | |
XMLCSTR | tag = NULL , |
|||
XMLResults * | pResults = NULL | |||
) | [static] |
Parse an XML file and return the root of a XMLNode tree representing the file.
The "parseFile" function parse an XML file and return the root of a XMLNode tree. The "opposite" of this function is the function "writeToFile" that re-creates an XML file from an XMLNode tree. If the XML document is corrupted, the "parseFile" method will initialize the "pResults" variable with some information that can be used to trace the error. If you still want to parse the file, you can use the APPROXIMATE_PARSING option as explained inside the note at the beginning of the "xmlParser.cpp" file.
filename | the path to the XML file to parse | |
tag | the name of the first tag inside the XML file. If the tag parameter is omitted, this function returns a node that represents the head of the xml document including the declaration term (<? ... ?>). | |
pResults | a pointer to a XMLResults variable that will contain some information that can be used to trace the XML parsing error. You can have a user-friendly explanation of the parsing error with the "getError" function. |
static XMLNode XMLNode::parseFile | ( | XMLCSTR | filename, | |
XMLCSTR | tag = NULL , |
|||
XMLResults * | pResults = NULL | |||
) | [static] |
Parse an XML file and return the root of a XMLNode tree representing the file.
The "parseFile" function parse an XML file and return the root of a XMLNode tree. The "opposite" of this function is the function "writeToFile" that re-creates an XML file from an XMLNode tree. If the XML document is corrupted, the "parseFile" method will initialize the "pResults" variable with some information that can be used to trace the error. If you still want to parse the file, you can use the APPROXIMATE_PARSING option as explained inside the note at the beginning of the "xmlParser.cpp" file.
filename | the path to the XML file to parse | |
tag | the name of the first tag inside the XML file. If the tag parameter is omitted, this function returns a node that represents the head of the xml document including the declaration term (<? ... ?>). | |
pResults | a pointer to a XMLResults variable that will contain some information that can be used to trace the XML parsing error. You can have a user-friendly explanation of the parsing error with the "getError" function. |
static XMLNode XMLNode::parseString | ( | XMLCSTR | lpXMLString, | |
XMLCSTR | tag = NULL , |
|||
XMLResults * | pResults = NULL | |||
) | [static] |
Parse an XML string and return the root of a XMLNode tree representing the string.
The "parseString" function parse an XML string and return the root of a XMLNode tree. The "opposite" of this function is the function "createXMLString" that re-creates an XML string from an XMLNode tree. If the XML document is corrupted, the "parseString" method will initialize the "pResults" variable with some information that can be used to trace the error. If you still want to parse the file, you can use the APPROXIMATE_PARSING option as explained inside the note at the beginning of the "xmlParser.cpp" file.
lpXMLString | the XML string to parse | |
tag | the name of the first tag inside the XML file. If the tag parameter is omitted, this function returns a node that represents the head of the xml document including the declaration term (<? ... ?>). | |
pResults | a pointer to a XMLResults variable that will contain some information that can be used to trace the XML parsing error. You can have a user-friendly explanation of the parsing error with the "getError" function. |
static XMLNode XMLNode::parseString | ( | XMLCSTR | lpXMLString, | |
XMLCSTR | tag = NULL , |
|||
XMLResults * | pResults = NULL | |||
) | [static] |
Parse an XML string and return the root of a XMLNode tree representing the string.
The "parseString" function parse an XML string and return the root of a XMLNode tree. The "opposite" of this function is the function "createXMLString" that re-creates an XML string from an XMLNode tree. If the XML document is corrupted, the "parseString" method will initialize the "pResults" variable with some information that can be used to trace the error. If you still want to parse the file, you can use the APPROXIMATE_PARSING option as explained inside the note at the beginning of the "xmlParser.cpp" file.
lpXMLString | the XML string to parse | |
tag | the name of the first tag inside the XML file. If the tag parameter is omitted, this function returns a node that represents the head of the xml document including the declaration term (<? ... ?>). | |
pResults | a pointer to a XMLResults variable that will contain some information that can be used to trace the XML parsing error. You can have a user-friendly explanation of the parsing error with the "getError" function. |
static char XMLNode::setGlobalOptions | ( | XMLCharEncoding | characterEncoding = XMLNode::char_encoding_UTF8 , |
|
char | guessWideCharChars = 1 , |
|||
char | dropWhiteSpace = 1 , |
|||
char | removeCommentsInMiddleOfText = 1 | |||
) | [static] |
Sets the global options for the conversions.
The "setGlobalOptions" function allows you to change four global parameters that affect string & file parsing. First of all, you most-probably will never have to change these 3 global parameters.
guessWideCharChars | If "guessWideCharChars"=1 and if this library is compiled in WideChar mode, then the XMLNode::parseFile and XMLNode::openFileHelper functions will test if the file contains ASCII characters. If this is the case, then the file will be loaded and converted in memory to WideChar before being parsed. If 0, no conversion will be performed. | |
guessWideCharChars | If "guessWideCharChars"=1 and if this library is compiled in ASCII/UTF8/char* mode, then the XMLNode::parseFile and XMLNode::openFileHelper functions will test if the file contains WideChar characters. If this is the case, then the file will be loaded and converted in memory to ASCII/UTF8/char* before being parsed. If 0, no conversion will be performed. | |
characterEncoding | This parameter is only meaningful when compiling in char* mode (multibyte character mode). In wchar_t* (wide char mode), this parameter is ignored. This parameter should be one of the three currently recognized encodings: XMLNode::encoding_UTF8, XMLNode::encoding_ascii, XMLNode::encoding_ShiftJIS. | |
dropWhiteSpace | In most situations, text fields containing only white spaces (and carriage returns) are useless. Even more, these "empty" text fields are annoying because they increase the complexity of the user's code for parsing. So, 99% of the time, it's better to drop the "empty" text fields. However The XML specification indicates that no white spaces should be lost when parsing the file. So to be perfectly XML-compliant, you should set dropWhiteSpace=0. A note of caution: if you set "dropWhiteSpace=0", the parser will be slower and your code will be more complex. | |
removeCommentsInMiddleOfText | To explain this parameter, let's consider this code:
XMLNode x=XMLNode::parseString("<a>foo<!-- hello -->bar<!DOCTYPE world >chu</a>","a"); If removeCommentsInMiddleOfText=0, then we will have: x.getText(0) -> "foo" x.getText(1) -> "bar" x.getText(2) -> "chu" x.getClear(0) --> "<!-- hello -->" x.getClear(1) --> "<!DOCTYPE world >" If removeCommentsInMiddleOfText=1, then we will have: |
static char XMLNode::setGlobalOptions | ( | XMLCharEncoding | characterEncoding = XMLNode::char_encoding_UTF8 , |
|
char | guessWideCharChars = 1 , |
|||
char | dropWhiteSpace = 1 , |
|||
char | removeCommentsInMiddleOfText = 1 | |||
) | [static] |
Sets the global options for the conversions.
The "setGlobalOptions" function allows you to change four global parameters that affect string & file parsing. First of all, you most-probably will never have to change these 3 global parameters.
guessWideCharChars | If "guessWideCharChars"=1 and if this library is compiled in WideChar mode, then the XMLNode::parseFile and XMLNode::openFileHelper functions will test if the file contains ASCII characters. If this is the case, then the file will be loaded and converted in memory to WideChar before being parsed. If 0, no conversion will be performed. | |
guessWideCharChars | If "guessWideCharChars"=1 and if this library is compiled in ASCII/UTF8/char* mode, then the XMLNode::parseFile and XMLNode::openFileHelper functions will test if the file contains WideChar characters. If this is the case, then the file will be loaded and converted in memory to ASCII/UTF8/char* before being parsed. If 0, no conversion will be performed. | |
characterEncoding | This parameter is only meaningful when compiling in char* mode (multibyte character mode). In wchar_t* (wide char mode), this parameter is ignored. This parameter should be one of the three currently recognized encodings: XMLNode::encoding_UTF8, XMLNode::encoding_ascii, XMLNode::encoding_ShiftJIS. | |
dropWhiteSpace | In most situations, text fields containing only white spaces (and carriage returns) are useless. Even more, these "empty" text fields are annoying because they increase the complexity of the user's code for parsing. So, 99% of the time, it's better to drop the "empty" text fields. However The XML specification indicates that no white spaces should be lost when parsing the file. So to be perfectly XML-compliant, you should set dropWhiteSpace=0. A note of caution: if you set "dropWhiteSpace=0", the parser will be slower and your code will be more complex. | |
removeCommentsInMiddleOfText | To explain this parameter, let's consider this code:
XMLNode x=XMLNode::parseString("<a>foo<!-- hello -->bar<!DOCTYPE world >chu</a>","a"); If removeCommentsInMiddleOfText=0, then we will have: x.getText(0) -> "foo" x.getText(1) -> "bar" x.getText(2) -> "chu" x.getClear(0) --> "<!-- hello -->" x.getClear(1) --> "<!DOCTYPE world >" If removeCommentsInMiddleOfText=1, then we will have: |
XMLError XMLNode::writeToFile | ( | XMLCSTR | filename, | |
const char * | encoding = NULL , |
|||
char | nFormat = 1 | |||
) | const |
Save the content of an xmlNode inside a file.
If nFormat==0, no formatting is required otherwise this returns an user friendly XML string from a given element with appropriate white spaces and carriage returns. If the global parameter "characterEncoding==encoding_UTF8", then the "encoding" parameter is ignored and always set to "utf-8". If the global parameter "characterEncoding==encoding_ShiftJIS", then the "encoding" parameter is ignored and always set to "SHIFT-JIS". If "_XMLWIDECHAR=1", then the "encoding" parameter is ignored and always set to "utf-16". If no "encoding" parameter is given the "ISO-8859-1" encoding is used.
XMLError XMLNode::writeToFile | ( | XMLCSTR | filename, | |
const char * | encoding = NULL , |
|||
char | nFormat = 1 | |||
) | const |
Save the content of an xmlNode inside a file.
If nFormat==0, no formatting is required otherwise this returns an user friendly XML string from a given element with appropriate white spaces and carriage returns. If the global parameter "characterEncoding==encoding_UTF8", then the "encoding" parameter is ignored and always set to "utf-8". If the global parameter "characterEncoding==encoding_ShiftJIS", then the "encoding" parameter is ignored and always set to "SHIFT-JIS". If "_XMLWIDECHAR=1", then the "encoding" parameter is ignored and always set to "utf-16". If no "encoding" parameter is given the "ISO-8859-1" encoding is used.