C++ Based OPC UA Client/Server SDK
1.6.1.391
|
XML parser class for an XML document. More...
#include <xmldocument.h>
Public Member Functions | |
UaXmlDocument () | |
Constructs an XML document object with default settings. More... | |
UaXmlDocument (const char *strFilePath) | |
Constructs an XML document object and loads the passed XML document file. More... | |
~UaXmlDocument () | |
Destroys the XML document object. More... | |
int | loadXmlFile (const char *strFilePath) |
Loads the XML document from the passed file name. More... | |
int | loadXmlText (const char *strText, int size, const char *url) |
Loads the XML document from the passed string. More... | |
int | create (const char *pchRootNode, const char *pchSimpleContent) |
Frees the XmlDocument. More... | |
int | freeXmlDocument () |
Unloads the XML document and frees the resources. More... | |
int | saveXmlFile (const char *strFilePath) |
Saves the XML document to the passed file name. More... | |
int | dumpXmlFile (char **pszContent, int &rSize) |
Dumps the whole XML file to pszContent. More... | |
int | dumpCurrentNode (char **pszContent, int &rSize) |
Dumps the current working node file to pszContent. More... | |
int | getRootNode () |
Sets current XML element working node to root node. More... | |
int | getFirstChild () |
Sets current XML element working node to the first child of the previous working node. More... | |
int | getChild (const char *pchName) |
Sets current XML element working node to the child with the given name below the previous working node. More... | |
int | getNextSibling () |
Sets current XML element working node to the next sibling of the previous working node. More... | |
int | getParentNode () |
Sets current XML element working node to the parent of the previous working node. More... | |
const char * | getNodeName () |
Gets the name of the current XML element working node. More... | |
void | getCurrentElement (UaXmlElement &uaXmlElement) |
Gets the current XML element working node as UaXmlElement. More... | |
void | deleteCurrentElement () |
Deletes the current XML element working node and set the working node to the parent of the deleted node. More... | |
int | getChildElements (const char *pchName, UaXmlElementList &uaXmlElementList) |
Returns a list of child XML elements with the given name. More... | |
void | getContent (UaXmlValue &value) |
Gets the content of the current XML element working node as UaXmlValue. More... | |
void | getAttributeValue (const char *pchAttributeName, UaXmlValue &value) |
Gets the content of the passed attribute name for the current XML element working node. More... | |
int | setContent (const char *pchSimpleContent) |
Sets the content of the current XML element working node as string. More... | |
int | addChild (const char *pchName, const char *pchSimpleContent) |
Adds a new child to the current XML element working node. More... | |
int | addChildNs (const char *pchName, const char *pchSimpleContent, const char *strNamespacePrefix) |
Adds a new child with xml namespace to the current XML element working node. More... | |
int | addAttribute (const char *pchName, const char *pchValue) |
Adds a new attribute to the current XML element working node. More... | |
int | setAttribute (const char *pchName, const char *pchValue) |
Sets the value of an attribute of the current XML element working node. More... | |
const char * | getNamespace () const |
Returns the Namespace of the current working node. More... | |
Static Public Member Functions | |
static void | initParser () |
Initializes the XML parser. More... | |
static void | cleanupParser () |
Cleans up the XML parser. More... | |
XML parser class for an XML document.
This class can be used to read or to create an XML file. The file is parsed and the content is temporarily stored in a Document Object Model (DOM). The class provides methods to navigate through the DOM and to read and write content to the DOM.
Note on usage:
See Tutorial Server Hello World and Getting Started Lesson 1 for example code.
UaXmlDocument::UaXmlDocument | ( | ) |
Constructs an XML document object with default settings.
UaXmlDocument::UaXmlDocument | ( | const char * | strFilePath | ) |
Constructs an XML document object and loads the passed XML document file.
[in] | strFilePath | File name and path for the XML document file to load. |
UaXmlDocument::~UaXmlDocument | ( | ) |
Destroys the XML document object.
int UaXmlDocument::addAttribute | ( | const char * | pchName, |
const char * | pchValue | ||
) |
Adds a new attribute to the current XML element working node.
[in] | pchName | Name of the new XML attribute |
[in] | pchValue | Content of the XML attribute |
int UaXmlDocument::addChild | ( | const char * | pchName, |
const char * | pchSimpleContent | ||
) |
Adds a new child to the current XML element working node.
Adds a child with the given name to the current XML element working node. If successful, the working node is set to the new node and 0 is returned. If pchSimpleContent is not NULL, the data will be added as content of the new node.
[in] | pchName | Name of the new child XML element node. |
[in] | pchSimpleContent | Content of the XML element. |
int UaXmlDocument::addChildNs | ( | const char * | pchName, |
const char * | pchSimpleContent, | ||
const char * | strNamespacePrefix | ||
) |
Adds a new child with xml namespace to the current XML element working node.
Adds a child with the given name and xml namespace to the current XML element working node. If successful, the working node is set to the new node and 0 is returned. If pchSimpleContent is not NULL, the data will be added as content of the new node.
[in] | pchName | Name of the new child XML element node. |
[in] | pchSimpleContent | Content of the XML element. |
|
static |
Cleans up the XML parser.
None of the xml functions can be used after the XML parser is released.
int UaXmlDocument::create | ( | const char * | pchRootNode, |
const char * | pchSimpleContent | ||
) |
Frees the XmlDocument.
Creates a new XmlDocument and sets the root node with the given name. If successful, the working node is set to the root node and 0 is returned. If pchSimpleContent is not NULL, the data will be added as content of the root node.
pchRootNode | Name of the root node, must not be NULL. |
pchSimpleContent | The content of the root node, can be NULL. |
void UaXmlDocument::deleteCurrentElement | ( | ) |
Deletes the current XML element working node and set the working node to the parent of the deleted node.
int UaXmlDocument::dumpCurrentNode | ( | char ** | pszContent, |
int & | rSize | ||
) |
Dumps the current working node file to pszContent.
int UaXmlDocument::dumpXmlFile | ( | char ** | pszContent, |
int & | rSize | ||
) |
Dumps the whole XML file to pszContent.
int UaXmlDocument::freeXmlDocument | ( | ) |
Unloads the XML document and frees the resources.
void UaXmlDocument::getAttributeValue | ( | const char * | pchAttributeName, |
UaXmlValue & | value | ||
) |
Gets the content of the passed attribute name for the current XML element working node.
[in] | pchAttributeName | The XML attribute name. |
[out] | value | The content of the XML attribute as UaXmlValue. |
int UaXmlDocument::getChild | ( | const char * | pchName | ) |
Sets current XML element working node to the child with the given name below the previous working node.
[in] | pchName | Name of the child node. |
int UaXmlDocument::getChildElements | ( | const char * | pchName, |
UaXmlElementList & | uaXmlElementList | ||
) |
Returns a list of child XML elements with the given name.
[in] | pchName | Name of the child XML element nodes. |
[out] | uaXmlElementList | The list of child XML element with the passed name as UaXmlElementList. |
void UaXmlDocument::getContent | ( | UaXmlValue & | value | ) |
Gets the content of the current XML element working node as UaXmlValue.
[out] | value | The content of the current XML element working node as UaXmlValue. |
void UaXmlDocument::getCurrentElement | ( | UaXmlElement & | uaXmlElement | ) |
Gets the current XML element working node as UaXmlElement.
[out] | uaXmlElement | The current working node as UaXmlElement |
int UaXmlDocument::getFirstChild | ( | ) |
Sets current XML element working node to the first child of the previous working node.
const char * UaXmlDocument::getNamespace | ( | ) | const |
Returns the Namespace of the current working node.
int UaXmlDocument::getNextSibling | ( | ) |
Sets current XML element working node to the next sibling of the previous working node.
const char * UaXmlDocument::getNodeName | ( | ) |
Gets the name of the current XML element working node.
int UaXmlDocument::getParentNode | ( | ) |
Sets current XML element working node to the parent of the previous working node.
int UaXmlDocument::getRootNode | ( | ) |
Sets current XML element working node to root node.
|
static |
Initializes the XML parser.
None of the xml functions can be used before the XML parser is initialized.
int UaXmlDocument::loadXmlFile | ( | const char * | strFilePath | ) |
Loads the XML document from the passed file name.
[in] | strFilePath | File name and path for the XML document file to load. |
int UaXmlDocument::loadXmlText | ( | const char * | strText, |
int | size, | ||
const char * | url | ||
) |
Loads the XML document from the passed string.
[in] | strText | String containing the XML document. |
[in] | size | The size of the array. |
[in] | url | The base URL to use for the document. |
int UaXmlDocument::saveXmlFile | ( | const char * | strFilePath | ) |
Saves the XML document to the passed file name.
[in] | strFilePath | File name and path for the XML document file to save to. |
int UaXmlDocument::setAttribute | ( | const char * | pchName, |
const char * | pchValue | ||
) |
Sets the value of an attribute of the current XML element working node.
[in] | pchName | Name of the XML attribute to change |
[in] | pchValue | Content of the XML attribute |
int UaXmlDocument::setContent | ( | const char * | pchSimpleContent | ) |
Sets the content of the current XML element working node as string.
[in] | pchSimpleContent | The new content for the XML element as string. |