src/Common/Xml/XmlDocument.h

Go to the documentation of this file.
00001 #pragma once
00002 
00003 namespace AppSecInc
00004 {
00005     namespace Xml
00006     {
00008         class XmlDocument
00009         {
00010         private:
00011             bool _loaded;
00012             MSXML2::IXMLDOMDocumentPtr _document;
00013                         static bool wstring2bool(const std::wstring&);
00014         public:
00015             XmlDocument();
00017             void Create(const CLSID clsid = MSXML2::CLSID_DOMDocument);
00019             void Load(const std::wstring& filename, const CLSID clsid = MSXML2::CLSID_DOMDocument);
00021             void LoadXml(const std::wstring& xml, const CLSID clsid = MSXML2::CLSID_DOMDocument);
00023                         MSXML2::IXMLDOMNodePtr FindNode(const std::wstring& xpath, MSXML2::IXMLDOMNode * = NULL) const;
00025             bool HasNodes(const std::wstring& xpath, MSXML2::IXMLDOMNode * = NULL) const;
00027             bool HasNode(const std::wstring& xpath, MSXML2::IXMLDOMNode * = NULL) const;
00029             MSXML2::IXMLDOMNodePtr SelectNode(const std::wstring& xpath, MSXML2::IXMLDOMNode * = NULL) const;
00031             MSXML2::IXMLDOMNodeListPtr SelectNodes(const std::wstring& xpath, MSXML2::IXMLDOMNode * = NULL) const;
00033             MSXML2::IXMLDOMNodeListPtr FindNodes(const std::wstring& xpath, MSXML2::IXMLDOMNode * = NULL) const;
00035                         std::wstring GetNodeXml(MSXML2::IXMLDOMNode * node) const;
00037                         std::wstring GetNodeValue(MSXML2::IXMLDOMNode * node) const;
00039                         bool GetNodeBoolValue(MSXML2::IXMLDOMNode * node) const;
00041                 bool GetNodeBoolValue(const std::wstring& xpath, MSXML2::IXMLDOMNode * = NULL) const;
00043                 bool GetNodeBoolValue(const std::wstring& xpath, MSXML2::IXMLDOMNode * parent, bool defaultvalue) const;
00045                 std::wstring GetNodeValue(const std::wstring& xpath, MSXML2::IXMLDOMNode * = NULL) const;
00047             std::wstring GetNodeValue(const std::wstring& xpath, MSXML2::IXMLDOMNode *, const std::wstring& defaultvalue) const;
00049                 std::wstring GetNodeXml(const std::wstring& xpath, MSXML2::IXMLDOMNode * = NULL) const;
00051                         std::wstring GetNodeXml(const std::wstring& xpath, MSXML2::IXMLDOMNode *, const std::wstring& defaultvalue) const;
00053             std::wstring GetXml() const;
00055                         MSXML2::IXMLDOMAttributePtr FindAttribute(const std::wstring& name, MSXML2::IXMLDOMNode * node) const;
00057                         std::wstring GetAttributeValue(MSXML2::IXMLDOMAttribute * attribute) const;
00059                         bool GetAttributeBoolValue(MSXML2::IXMLDOMAttribute * attribute) const;
00061                 std::wstring GetAttributeValue(const std::wstring& xpath, const std::wstring& attributename, MSXML2::IXMLDOMNode * = NULL) const;
00063             MSXML2::IXMLDOMNodePtr AppendChild(const std::wstring& name, MSXML2::IXMLDOMNode * parent = NULL, const _variant_t & type = VT_NULL, LPCWSTR pszNamespaceUri = NULL);
00065             MSXML2::IXMLDOMAttributePtr SetAttribute(const std::wstring& name, const std::wstring& value, MSXML2::IXMLDOMNode * node);
00067             MSXML2::IXMLDOMAttributePtr SelectAttribute(const std::wstring& name, MSXML2::IXMLDOMNode *) const;
00069             bool HasAttribute(const std::wstring& name, MSXML2::IXMLDOMNode *) const;
00071                 bool GetAttributeBoolValue(const std::wstring& name, MSXML2::IXMLDOMNode *) const;
00073                 bool GetAttributeBoolValue(const std::wstring& name, MSXML2::IXMLDOMNode *, bool defaultvalue) const;
00075                 std::wstring GetAttributeValue(const std::wstring& name, MSXML2::IXMLDOMNode *) const;
00077             std::wstring GetAttributeValue(const std::wstring& name, MSXML2::IXMLDOMNode *, const std::wstring& defaultvalue) const;
00079                         std::wstring XslTransform(const std::wstring xslt_filename);
00081             MSXML2::IXMLDOMDocument * operator->() const throw() { return _document.operator->(); }
00083                         std::wstring GetParseError() const;
00084         };
00085     }
00086 }


© Application Security Inc. - All Rights Reserved http://msiext.codeplex.com