SECXMLDocument Class

class SECXMLDocument

The SECXMLDocument class provides a simplified method for creating and reading XML files and editing their content.

Defined in: XMLDomDoc.h

Comments

The class requires the latest XML DOM runtime (provided with IE 5 and above) and the latest Platform SDK for the latest XML DOM interface defenitions.
We use this class in our implementation of the SECXMLDOMArchive class, take a look at the source code of this class for usage pattern.
At any time this class maintains a map of child element tagnames of any node in the document hierarchy and a reference to their corresponding XML DOM interfaces. This way when you query for a child element within that node, the retrieval is very fast.

Class Members

inline SECXMLDocument()

Default constructor.

inline SECXMLDocument(LPTSTR strRootTag, LPTSTR strHeader=NULL)

Initialization constructor.

inline HRESULT Create(LPTSTR strRootTag, LPTSTR strHeader=NULL)

Creates an empty document with a root tag.

inline BOOL FindTextTag(const _bstr_t& strTag, _bstr_t& strValue)

Finds a tag and return a bstr value for the first text child.

inline BOOL FindElementTag(const _bstr_t& strTag, IXMLDOMNode** ppElement)

Finds the IXMLDOMNode pointer that matches the tag.

inline BOOL FindTextTag(const _bstr_t& strTag, CComVariant& vVal, VARTYPE vt)

Finds a tag and returns a variant representation of the first child.

inline void ClearMap(BOOL bRelease = TRUE)

Clears all elements of the map.

inline BOOL LoadMap()

Populates the text tag map with tagname,textchild values.

inline BOOL MapElements(IXMLDOMNode* pRoot, BOOL bRecurse = TRUE)

Builds the element map starting with the 'pRoot' parameter as the root element.

inline void Destroy()

Releases the msmxml parser.

inline void Attach(IXMLDOMDocument* pDoc)

Attach to an existing document.

inline HRESULT LoadFromFile(LPTSTR strFileName)

Populates from an existing XML file.

inline HRESULT SaveToFile(LPTSTR strFileName)

Saves to an XML file.

inline HRESULT AddTag(LPCTSTR strTagName, long nType, IXMLDOMNode** ppRetVal=NULL, IXMLDOMNode* pParent=NULL)

Adds a generic node.

inline HRESULT AddTextTag(LPCTSTR strTagName, LPCTSTR strText, long nType, IXMLDOMNode** ppRetVal=NULL, IXMLDOMNode* pParent=NULL)

Adds an element with a text child element.

inline HRESULT SetAttribute(IXMLDOMNode* pNode, LPTSTR strName, LPTSTR strValue)

Adds an attribute to an element.

inline BOOL GetTextTag(IXMLDOMNode* pElement, BSTR& strTag)

Gets the text value of the first child.