Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

226 lines
10 KiB

  1. /* @doc
  2. *
  3. * @module XMLDocUtils.h |
  4. *
  5. * Header file for XMLDocUtils.cpp
  6. *
  7. * Author: Ying-ping Chen (t-ypchen)
  8. */
  9. #pragma once
  10. // @func void | CreateXMLDocument | Create a new XML document
  11. // @rdesc None
  12. void CreateXMLDocument
  13. ( IXMLDOMDocument **ppXMLDoc // @parm [out] the created XML document
  14. );
  15. // @func void | XMLAddAttributeToElement | Add an attribute to an element
  16. // @syntax void XMLAddAttributeToElement(IXMLDOMDocument *pContextDoc, IXMLDOMElement *pElement, const BSTR bstrAttrName, const CComVariant &varAttrValue);
  17. // @syntax void XMLAddAttributeToElement(IXMLDOMDocument *pContextDoc, IXMLDOMElement *pElement, const LPCWSTR pwszAttrName, const LPCWSTR pwszAttrValue);
  18. // @rdesc None
  19. void XMLAddAttributeToElement
  20. ( IXMLDOMDocument *pContextDoc, // @parm [in] the XML context for creating the new attribute
  21. IXMLDOMElement *pElement, // @parm [in] the XML element
  22. const BSTR bstrAttrName, // @parm [in] the name of the attribute
  23. const CComVariant &varAttrValue // @parm [in] the value of the attribute
  24. );
  25. // Add an attribute to an element (a thin wrapper of the previous function)
  26. void XMLAddAttributeToElement
  27. ( IXMLDOMDocument *pContextDoc,
  28. IXMLDOMElement *pElement,
  29. const LPCWSTR pwszAttrName, // @parm [in] the name of the attribute
  30. const LPCWSTR pwszAttrValue // @parm [in] the value of the attribute
  31. );
  32. // @func void | XMLAddTextToElement | Add a text node to an element
  33. // @syntax void XMLAddTextToElement(IXMLDOMElement *pElement, const BSTR bstrText);
  34. // @syntax void XMLAddTextToElement(IXMLDOMElement *pElement, const LPCWSTR pwszText);
  35. // @rdesc None
  36. void XMLAddTextToElement
  37. ( IXMLDOMElement *pElement, // @parm [in] the XML element
  38. const BSTR bstrText // @parm [in] the text of the text node
  39. );
  40. // Add a text node to an element (a thin wrapper of the previous function)
  41. void XMLAddTextToElement
  42. ( IXMLDOMElement *pElement,
  43. const LPCWSTR pwszText // @parm [in] the text of the text node
  44. );
  45. // @func void | XMLAddElementToNode |
  46. // Add an element to a node,
  47. // add an element to a node with a text node, or
  48. // add an element to a node with an attribute.
  49. // @syntax void XMLAddElementToNode(IXMLDOMDocument *pContextDoc, IXMLDOMNode *pParentNode, const BSTR bstrTagName, IXMLDOMElement **ppElement, IXMLDOMNode **ppNode = NULL);
  50. // @syntax void XMLAddElementToNode(IXMLDOMDocument *pContextDoc, IXMLDOMNode *pParentNode, const LPCWSTR pwszTagName, IXMLDOMElement **ppElement, IXMLDOMNode **ppNode = NULL);
  51. // @syntax void XMLAddElementToNode(IXMLDOMDocument *pContextDoc, IXMLDOMNode *pParentNode, const BSTR bstrTagName, const BSTR bstrText, IXMLDOMElement **ppElement, IXMLDOMNode **ppNode = NULL);
  52. // @syntax void XMLAddElementToNode(IXMLDOMDocument *pContextDoc, IXMLDOMNode *pParentNode, const LPCWSTR pwszTagName, const LPCWSTR pwszText, IXMLDOMElement **ppElement, IXMLDOMNode **ppNode = NULL);
  53. // @syntax void XMLAddElementToNode(IXMLDOMDocument *pContextDoc, IXMLDOMNode *pParentNode, const BSTR bstrTagName, const BSTR bstrAttrName, const CComVariant &varAttrValue, IXMLDOMElement **ppElement, IXMLDOMNode **ppNode = NULL);
  54. // @syntax void XMLAddElementToNode(IXMLDOMDocument *pContextDoc, IXMLDOMNode *pParentNode, const LPCWSTR pwszTagName, const LPCWSTR pwszAttrName, const LPCWSTR pwszAttrValue, IXMLDOMElement **ppElement, IXMLDOMNode **ppNode = NULL);
  55. // @rdesc None
  56. void XMLAddElementToNode
  57. ( IXMLDOMDocument *pContextDoc, // @parm [in] the XML context for creating the new element
  58. IXMLDOMNode *pParentNode, // @parm [in] the parent node
  59. const BSTR bstrTagName, // @parm [in] the tag of the new element
  60. IXMLDOMElement **ppElement, // @parm [out] the created element
  61. IXMLDOMNode **ppNode = NULL // @parmopt [out] (Optional) the XML node interface to the created element
  62. );
  63. // Add an element to a node (a thin wrapper of the previous function)
  64. void XMLAddElementToNode
  65. ( IXMLDOMDocument *pContextDoc,
  66. IXMLDOMNode *pParentNode,
  67. const LPCWSTR pwszTagName, // @parm [in] the tag of the new element
  68. IXMLDOMElement **ppElement,
  69. IXMLDOMNode **ppNode = NULL
  70. );
  71. // Add an element to a node with a text node
  72. // [in] pContextDoc - the XML context for creating the new element
  73. // [in] pParentNode - the parent node
  74. // [in] bstrTagName - the tag of the new node
  75. // [in] bstrText - the text of the text node
  76. // [out] ppElement - the pointer to the pointer to the created element
  77. // [out] ppNode - (Optional) the pointer to the pointer to the XML
  78. // node interface to the created element
  79. void XMLAddElementToNode
  80. ( IXMLDOMDocument *pContextDoc,
  81. IXMLDOMNode *pParentNode,
  82. const BSTR bstrTagName,
  83. const BSTR bstrText, // @parm [in] the text of the text node
  84. IXMLDOMElement **ppElement,
  85. IXMLDOMNode **ppNode = NULL
  86. );
  87. // Add an element to a node with a text node
  88. // (a thin wrapper of the previous function)
  89. void XMLAddElementToNode
  90. ( IXMLDOMDocument *pContextDoc,
  91. IXMLDOMNode *pParentNode,
  92. const LPCWSTR pwszTagName,
  93. const LPCWSTR pwszText, // @parm [in] the text of the text node
  94. IXMLDOMElement **ppElement,
  95. IXMLDOMNode **ppNode = NULL
  96. );
  97. // Add an element to a node with an attribute
  98. // [in] pContextDoc - the XML context for creating the new element
  99. // [in] pParentNode - the parent node
  100. // [in] bstrTagName - the tag of the new element
  101. // [in] bstrAttrName - the name of the attribute of the new element
  102. // [in] varAttrValue - the value of the attribute of the new element
  103. // [out] ppElement - the pointer to the pointer to the created element
  104. // [out] ppNode - (Optional) the pointer to the pointer to the XML
  105. // node interface to the created element
  106. void XMLAddElementToNode
  107. ( IXMLDOMDocument *pContextDoc,
  108. IXMLDOMNode *pParentNode,
  109. const BSTR bstrTagName,
  110. const BSTR bstrAttrName, // @parm [in] the name of the attribute of the new element
  111. const CComVariant &varAttrValue, // @parm [in] the value of the attribute of the new element
  112. IXMLDOMElement **ppElement,
  113. IXMLDOMNode **ppNode = NULL
  114. );
  115. // Add an element to a node with an attribute
  116. // (a thin wrapper of the previous function)
  117. void XMLAddElementToNode
  118. ( IXMLDOMDocument *pContextDoc,
  119. IXMLDOMNode *pParentNode,
  120. const LPCWSTR pwszTagName,
  121. const LPCWSTR pwszAttrName, // @parm [in] the name of the attribute of the new element
  122. const LPCWSTR pwszAttrValue, // @parm [in] the value of the attribute of the new element
  123. IXMLDOMElement **ppElement,
  124. IXMLDOMNode **ppNode = NULL
  125. );
  126. // @func HRESULT | ParseXML | Parse an XML document
  127. // @syntax HRESULT ParseXML(const BSTR bstrXML, IXMLDOMDocument **ppXMLDoc);
  128. // @syntax HRESULT ParseXML(const LPCSTR pwszXML, IXMLDOMDocument **ppXMLDoc);
  129. // @syntax HRESULT ParseXML(const LPCSTR pszXML, IXMLDOMDocument **ppXMLDoc);
  130. // @rdesc Return the following values:
  131. // @flag S_OK | successful
  132. // @flag Otherwise | parse error
  133. HRESULT ParseXML
  134. ( const BSTR bstrXML, // @parm [in] the XML content
  135. IXMLDOMDocument **ppXMLDoc // @parm [out] the XML document object
  136. );
  137. // Parse an XML document
  138. // (a thin wrapper of the previous function)
  139. HRESULT ParseXML
  140. ( const LPCWSTR pwszXML, // @parm [in] the XML content
  141. IXMLDOMDocument **ppXMLDoc
  142. );
  143. // Parse an XML document
  144. // (a thin wrapper of the previous function)
  145. HRESULT ParseXML
  146. ( const LPCSTR pszXML, // @parm [in] the XML content
  147. IXMLDOMDocument **ppXMLDoc
  148. );
  149. // @func void | XMLToString | Output an XML document to a string object
  150. // @syntax void XMLToString(IXMLDOMNode *pXMLRootNode, CStringW &cwszDoc);
  151. // @syntax void XMLToString(IXMLDOMNode *pXMLRootNode, CStringA &cszDoc);
  152. // @rdesc None
  153. void XMLToString
  154. ( IXMLDOMNode *pXMLRootNode, // @parm [in] the root node of the XML document to be output
  155. CStringW &cwszDoc // @parm [out] the string object holding the XML document
  156. );
  157. // Output an XML document to a string object
  158. // (a thin wrapper of the previous function)
  159. void XMLToString
  160. ( IXMLDOMNode *pXMLRootNode,
  161. CStringA &cszDoc // @parm [out] the string object holding the XML document
  162. );
  163. // @func HRESULT | XMLLoadNodeText | Load the text of a node
  164. // @syntax HRESULT XMLLoadNodeText(IXMLDOMDocument *pXMLDoc, const LPCWSTR &pwszNodeName, CComBSTR &bstrNodeText);
  165. // @syntax HRESULT XMLLoadNodeText(IXMLDOMDocument *pXMLDoc, const LPCWSTR &pwszNodeName, CStringW &cwszNodeText);
  166. // @syntax HRESULT XMLLoadNodeText(IXMLDOMDocument *pXMLDoc, const LPCSTR &pszNodeName, CComBSTR &bstrNodeText);
  167. // @syntax HRESULT XMLLoadNodeText(IXMLDOMDocument *pXMLDoc, const LPCSTR &pszNodeName, CStringW &cwszNodeText);
  168. // @rdesc Return the following values:
  169. // @flag S_OK | successful
  170. // @flag PP_E_XML_NO_SUCH_NODE | the specified node is not found
  171. // @flag PP_E_XML_NO_TEXT | the specified node has no text
  172. HRESULT XMLLoadNodeText
  173. ( IXMLDOMDocument *pXMLDoc, // @parm [in] the XML document
  174. const LPCWSTR &pwszNodeName, // @parm [in] the name of the node
  175. CComBSTR &bstrNodeText // @parm [out] the text of the node (if S_OK)
  176. );
  177. // Load the text of a node (a thin wrapper of the previous function)
  178. HRESULT XMLLoadNodeText
  179. ( IXMLDOMDocument *pXMLDoc,
  180. const LPCWSTR &pwszNodeName,
  181. CStringW &cwszNodeText // @parm [out] the text of the node (if S_OK)
  182. );
  183. // Load the text of a node (a thin wrapper of the previous function)
  184. HRESULT XMLLoadNodeText
  185. ( IXMLDOMDocument *pXMLDoc,
  186. const LPCSTR &pszNodeName, // @parm [in] the name of the node
  187. CComBSTR &bstrNodeText
  188. );
  189. // Load the text of a node (a thin wrapper of the previous function)
  190. HRESULT XMLLoadNodeText
  191. ( IXMLDOMDocument *pXMLDoc,
  192. const LPCSTR &pszNodeName,
  193. CStringW &cwszNodeText
  194. );
  195. // @func HRESULT | XMLLoadAttribute | Load the attribute
  196. // @syntax HRESULT XMLLoadAttribute(IXMLDOMDocument *pXMLDoc, const LPCWSTR &pwszNodeName, const LPCWSTR &pwszAttrName, CComBSTR &bstrAttrValue);
  197. // @rdesc Return the following values:
  198. // @flag S_OK | successful
  199. // @flag PP_E_XML_NO_SUCH_NODE | the specified node is not found
  200. // @flag PP_E_XML_NO_SUCH_ATTRIBUTE | the specified attribute not found
  201. HRESULT XMLLoadAttribute
  202. ( IXMLDOMDocument *pXMLDoc, // @parm [in] the XML document
  203. const LPCWSTR &pwszNodeName, // @parm [in] the name of the node
  204. const LPCWSTR &pwszAttrName, // @parm [in] the name of the attribute
  205. CComBSTR &bstrAttrValue // @parm [out] the value of the attribute (if S_OK)
  206. );