I am creating an XML DOM document in C ++. My problem is this: I am executing an XPATH request from an element in my document that I know will return another element. A call to elementPtr-> selectSingleNode returns IXMLDOMNode. How to access the attributes of this node?
Part of me wants to reduce Node to an element, but I could not get the cast to work.
I tried
MSXML2::IXMLDOMElementPtr pParentElement;
pParentNode->QueryInterface(__uuidof(MSXML2::IXMLDOMElement),
(void**) &pParentElement);
This results in the following runtime error:
0x0057cc58 _com_error::`scalar deleting destructor'(unsigned int)
Another route I tried was just to use the nodes:
MSXML2::IXMLDOMNodePtr pParentNode =
pParameterElement->selectSingleNode("parent");
MSXML2::IXMLDOMNamedNodeMap* pParentAttributes;
pParentNode->get_attributes(&pParentAttributes);
MSXML2::IXMLDOMNodePtr pCategoryNameNode =
pParentAttributes->getNamedItem("Category");
VARIANT value;
pCategoryNameNode->get_nodeValue(&value);
CString categoryName = value;
This does not work with "parentNode-> get_attributes ()".
It seems like I'm missing something; The API should not be so difficult to use.
- edit -
, selectSingleNode , NULL. QueryInterface, get_attributes : P
, , , , , .