前些天看了一个XML帖子,学了MSXML的用法
我用的是ACCESS ODBC数据源,运行时出现RUNTIEM ERROR 请帮助void CAView::OnButtonG()
{
// TODO: Add your control notification handler code here
MSXML2::IXMLDOMDocumentPtr pDocPtr;
MSXML2::IXMLDOMElementPtr pRootElemPtr;
MSXML2::IXMLDOMElementPtr pChildNode, pTemp,pAp;
MSXML2::IXMLDOMProcessingInstructionPtr pPI=NULL; pDocPtr.CreateInstance(__uuidof(MSXML2::DOMDocument30));
pDocPtr->raw_createProcessingInstruction(_bstr_t(L"xml"),_bstr_t(L"version='1.0' encoding='utf-8'"),&pPI);
pDocPtr->appendChild(pPI); CASet cSet;
cSet.Open();
CODBCFieldInfo field;
CString str,str2=cSet.GetTableName(),str1;
pDocPtr->raw_createElement(_bstr_t(cSet.GetTableName()), &pRootElemPtr);
pDocPtr->raw_appendChild(pRootElemPtr, NULL); while(!cSet.IsEOF())
{
pDocPtr->raw_createElement(_bstr_t("Records"), &pAp);
pRootElemPtr->raw_appendChild(pAp, NULL);
for(UINT i=1;i<cSet.GetODBCFieldCount();i++)
{
CString strvalue;
cSet.GetODBCFieldInfo(i,field);
cSet.GetFieldValue(i,strvalue);
pDocPtr->raw_createElement((_bstr_t)field.m_strName, &pChildNode);
pChildNode->Puttext((_bstr_t)strvalue);
pAp->appendChild(pChildNode); }
cSet.MoveNext();
}
pDocPtr->save("f:""pjx.xml");
MessageBox("xml file has been generated ");
}
我用的是ACCESS ODBC数据源,运行时出现RUNTIEM ERROR 请帮助void CAView::OnButtonG()
{
// TODO: Add your control notification handler code here
MSXML2::IXMLDOMDocumentPtr pDocPtr;
MSXML2::IXMLDOMElementPtr pRootElemPtr;
MSXML2::IXMLDOMElementPtr pChildNode, pTemp,pAp;
MSXML2::IXMLDOMProcessingInstructionPtr pPI=NULL; pDocPtr.CreateInstance(__uuidof(MSXML2::DOMDocument30));
pDocPtr->raw_createProcessingInstruction(_bstr_t(L"xml"),_bstr_t(L"version='1.0' encoding='utf-8'"),&pPI);
pDocPtr->appendChild(pPI); CASet cSet;
cSet.Open();
CODBCFieldInfo field;
CString str,str2=cSet.GetTableName(),str1;
pDocPtr->raw_createElement(_bstr_t(cSet.GetTableName()), &pRootElemPtr);
pDocPtr->raw_appendChild(pRootElemPtr, NULL); while(!cSet.IsEOF())
{
pDocPtr->raw_createElement(_bstr_t("Records"), &pAp);
pRootElemPtr->raw_appendChild(pAp, NULL);
for(UINT i=1;i<cSet.GetODBCFieldCount();i++)
{
CString strvalue;
cSet.GetODBCFieldInfo(i,field);
cSet.GetFieldValue(i,strvalue);
pDocPtr->raw_createElement((_bstr_t)field.m_strName, &pChildNode);
pChildNode->Puttext((_bstr_t)strvalue);
pAp->appendChild(pChildNode); }
cSet.MoveNext();
}
pDocPtr->save("f:""pjx.xml");
MessageBox("xml file has been generated ");
}
HOWTO: A C++ Sample of ADO Recordset XML Persistence