从Web站点读取xml的问题.
CoInitialize(NULL);
IXMLDOMDocumentPtr m_plDomDocument;
IXMLDOMElementPtr m_pDocRoot;
IXMLDOMNodePtr m_pDocNode;
HRESULT hr = m_plDomDocument.CreateInstance(CLSID_DOMDocument);
if (FAILED(hr))
{
_com_error er(hr);
AfxMessageBox(er.ErrorMessage());
}
// specify xml file name
CString strFileName ("http://youth.fzu.edu.cn/NetMsg/test.asp");
_bstr_t bstrFileName;
bstrFileName = strFileName.AllocSysString();
variant_t vResult;
vResult = m_plDomDocument->load(bstrFileName);
if (((bool)vResult) == TRUE) // 成功的
{
// now that the document is loaded, we need to initialize the root pointer
m_pDocRoot = m_plDomDocument->documentElement;
m_pDocNode = m_pDocRoot->selectSingleNode("//TestName");
AfxMessageBox(m_plDomDocument->xml);//出问题,空的
//AfxMessageBox(m_pDocNode->text);
}
else
{
AfxMessageBox("Document FAILED to load!");
}
test.asp是写成xml的.
就是:Response.content="text/xml"