PeterVanT
January 18th, 2002, 09:51 AM
Can anyone tell me way the CreateComment in the code below is working fine and the CreateProcessingInstruction is generating an exception (the object is not created.
xml::IXMLDOMDocumentPtr spDoc;
xml::IXMLDOMNodeListPtr spNodeListTmp;
xml::IXMLDOMElementPtr spRootElement;
xml::IXMLDOMElementPtr spProduct;
xml::IXMLDOMElementPtr spElektronikonDefinition;
xml::IXMLDOMElementPtr spProductDefinition;
xml::IXMLDOMElementPtr spStatus;
xml::IXMLDOMProcessingInstructionPtr spIXMLDOMProcessingInstruction;
xml::IXMLDOMCommentPtr spComment;
hRes=spDoc.CreateInstance(__uuidof(xml::DOMDocument));
if (FAILED(hRes)) return FALSE;
try
{
spComment=spDoc->createComment("test");
}
catch (...)
{
MessageBox(NULL, _T("Exception occurred"), _T("Error"), MB_OK);
}
try
{
spIXMLDOMProcessingInstruction=spDoc->createProcessingInstruction(_bstr_t("xml"), _bstr_t("Version=""1.0"""));
}
catch (...)
{
MessageBox(NULL, _T("Exception occurred"), _T("Error"), MB_OK);
}
spDoc->appendChild(spIXMLDOMProcessingInstruction);
xml::IXMLDOMDocumentPtr spDoc;
xml::IXMLDOMNodeListPtr spNodeListTmp;
xml::IXMLDOMElementPtr spRootElement;
xml::IXMLDOMElementPtr spProduct;
xml::IXMLDOMElementPtr spElektronikonDefinition;
xml::IXMLDOMElementPtr spProductDefinition;
xml::IXMLDOMElementPtr spStatus;
xml::IXMLDOMProcessingInstructionPtr spIXMLDOMProcessingInstruction;
xml::IXMLDOMCommentPtr spComment;
hRes=spDoc.CreateInstance(__uuidof(xml::DOMDocument));
if (FAILED(hRes)) return FALSE;
try
{
spComment=spDoc->createComment("test");
}
catch (...)
{
MessageBox(NULL, _T("Exception occurred"), _T("Error"), MB_OK);
}
try
{
spIXMLDOMProcessingInstruction=spDoc->createProcessingInstruction(_bstr_t("xml"), _bstr_t("Version=""1.0"""));
}
catch (...)
{
MessageBox(NULL, _T("Exception occurred"), _T("Error"), MB_OK);
}
spDoc->appendChild(spIXMLDOMProcessingInstruction);