UA Server SDK C++ Bundle  1.4.0.258
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
UaXmlDocument Class Reference

XML parser class for a XML document. More...

#include <xmldocument.h>

Public Member Functions

 UaXmlDocument ()
 Constructs a XML document object with default settings.
 
 UaXmlDocument (const char *strFilePath)
 Constructs a XML document object and loads the passed XML document file. More...
 
 ~UaXmlDocument ()
 Destroys the XML document object.
 
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)
 
int dumpCurrentNode (char **pszContent, int &rSize)
 
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 ()
 Get the name of the current XML element working node. More...
 
void getCurrentElement (UaXmlElement &xmlElement)
 Get the current XML element working node as UaXmlElement. More...
 
void deleteCurrentElement ()
 Delete 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)
 Get the content of the current XML element working node as UaXmlValue. More...
 
void getAttributeValue (const char *pchAttributeName, UaXmlValue &value)
 Get the content of the passed attribute name for the current XML element working node. More...
 
int setContent (const char *pchSimpleContent)
 Set 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 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
 
const char * getLastXmlErrorString () const
 
int getLastXmlErrorLine () const
 
int setNamespace (const char *strNamespace, const char *strNamespacePrefix=OpcUa_Null)
 

Static Public Member Functions

static void initParser ()
 Initialize XML parser. More...
 
static void cleanupParser ()
 Clean up XML parser. More...
 

Detailed Description

XML parser class for a XML document.

Constructor & Destructor Documentation

UaXmlDocument::UaXmlDocument ( const char *  strFilePath)

Constructs a XML document object and loads the passed XML document file.

Parameters
[in]strFilePathFile name and path for the XML document file to load

Member Function Documentation

int UaXmlDocument::addAttribute ( const char *  pchName,
const char *  pchValue 
)

Adds a new attribute to the current XML element working node.

Returns
0 for success. -1 if method fails
Parameters
[in]pchNameName of the new XML attribute
[in]pchValueContent 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 given name to the current XML element working node. If successful, the work 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.

Returns
0 for success. -1 if method fails
Parameters
[in]pchNameName of the new child XML element node
[in]pchSimpleContentContent of the XML element
void UaXmlDocument::cleanupParser ( )
static

Clean up XML parser.

None of the xml functions 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 given name. If successful, the work 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.

Parameters
pchRootNodeName of the root node, must not be NULL
pchSimpleContentThe content of the root node, can be NULL
Returns
0 for success. -1 if method fails.
void UaXmlDocument::deleteCurrentElement ( )

Delete the current XML element working node and set the working node to the parent of the deleted node.

Returns
0 for success. -1 if method fails
int UaXmlDocument::freeXmlDocument ( )

Unloads the XML document and frees the resources.

Returns
0 for success
void UaXmlDocument::getAttributeValue ( const char *  pchAttributeName,
UaXmlValue value 
)

Get the content of the passed attribute name for the current XML element working node.

Parameters
[in]pchAttributeNameThe XML attribute name
[out]valueThe 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.

Returns
0 for success. -1 if method fails
Parameters
[in]pchNameName of the child node
int UaXmlDocument::getChildElements ( const char *  pchName,
UaXmlElementList uaXmlElementList 
)

Returns a list of child XML elements with the given name.

Returns
0 for success. -1 if method fails
Parameters
[in]pchNameName of the child XML element nodes
[out]uaXmlElementListThe list of child XML element with the passed name as UaXmlElementList
void UaXmlDocument::getContent ( UaXmlValue value)

Get the content of the current XML element working node as UaXmlValue.

Parameters
[out]valueThe content of the current XML element working node as UaXmlValue
void UaXmlDocument::getCurrentElement ( UaXmlElement xmlElement)

Get the current XML element working node as UaXmlElement.

Parameters
[out]xmlElementThe current working node as UaXmlElement
int UaXmlDocument::getFirstChild ( )

Sets current XML element working node to the first child of the previous working node.

Returns
0 for success. -1 if method fails
int UaXmlDocument::getNextSibling ( )

Sets current XML element working node to the next sibling of the previous working node.

Returns
0 for success. -1 if method fails
const char * UaXmlDocument::getNodeName ( )

Get the name of the current XML element working node.

Returns
The name for success. NULL if method fails
int UaXmlDocument::getParentNode ( )

Sets current XML element working node to the parent of the previous working node.

Returns
0 for success. -1 if method fails
int UaXmlDocument::getRootNode ( )

Sets current XML element working node to root node.

Returns
0 for success
void UaXmlDocument::initParser ( )
static

Initialize XML parser.

None of the xml functions 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.

Returns
0 for successful loading. -1 if loading failed
Parameters
[in]strFilePathFile 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.

Returns
0 for successful loading. -1 if loading failed
Parameters
[in]strTextString containing the XML docuemnt
[in]sizeThe size of the array
[in]urlThe base URL to use for the document
int UaXmlDocument::saveXmlFile ( const char *  strFilePath)

Saves the XML document to the passed file name.

Returns
0 for unsuccessful save. -1 if saving failed
Parameters
[in]strFilePathFile 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.

Returns
0 for success. -1 if method fails
Parameters
[in]pchNameName of the XML attribute to change
[in]pchValueContent of the XML attribute
int UaXmlDocument::setContent ( const char *  pchSimpleContent)

Set the content of the current XML element working node as string.

Parameters
[in]pchSimpleContentThe new content for the XML element as string

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