Okay, in stdafx.h I have #import "msxml4.dll"... which seems to be working
fine, as I have access to the appropriate methods and lists involved. The
code I'm having difficulty with is below... at the end of the execution,
NumRaces has 0 in it and xmlNode is NULL. Icky. Using the de{*filter*} I can
confirm that the file is loading from the file just fine, something after
that point is going wrong. (The xml file is well-formed and does not use a
DTD) This isn't for anything important, I'm just trying to learn the
MSXMLDOM, but assistance would be appreciated all the same, before I tear my
own eyeballs out :)
Thanks,
-Dale
IXMLDOMDocumentPtr docPtr;
IXMLDOMElement* xmlRoot;
IXMLDOMNodeList* xmlnodeRaces;
IXMLDOMNode* xmlNode;
long NumRaces;
HRESULT hr;
VARIANT_BOOL varOut;
try{
docPtr.CreateInstance("msxml2.domdocument");
// load document
CComVariant varXml("C:\\pcgen.xml");
docPtr->put_async (false);
docPtr->put_validateOnParse(true);
docPtr->put_resolveExternals(true);
// docPtr->preserveWhiteSpace=false;
varOut = docPtr->load(varXml);
if (varOut == FALSE)
{
return E_FAIL;
}
docPtr->get_documentElement(&xmlRoot);
CComBSTR tmp;
docPtr->get_xml(&tmp);
CString cstrtmp = OLE2A(tmp);
varOut = xmlRoot->hasChildNodes();
CComBSTR bstrRace("race");
xmlnodeRaces = docPtr->selectNodes((BSTR)bstrRace);
xmlnodeRaces->get_length(&NumRaces);
xmlNode = xmlnodeRaces->Getitem(0L);
///.... continues but the rest is irrelevant here