API 使用 XML的COM组件
来源:互联网 发布:数据库系统书籍 编辑:程序博客网 时间:2024/04/30 22:10
#include <windows.h>
#import "C:/WINDOWS/system32/msxml3.dll" named_guids
using namespace MSXML2;
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.
::CoInitialize(NULL);
IXMLDOMDocumentPtr m_plDomDocument;
IXMLDOMElementPtr m_pDocRoot;
HRESULT hr = m_plDomDocument.CreateInstance(CLSID_DOMDocument);
if (FAILED(hr))
{
_com_error er(hr);
//AfxMessageBox(er.ErrorMessage());
//EndDialog(1);
}
_bstr_t bstrFileName = "a.xml";
variant_t vResult;
vResult = m_plDomDocument->load(bstrFileName);
if (((bool)vResult) == TRUE) // success!
{
// now that the document is loaded, we need to initialize the root pointer
m_pDocRoot = m_plDomDocument->documentElement;
//AfxMessageBox("Document loaded successfully!");
}
else
{
//AfxMessageBox("Document FAILED to load!");
}
IXMLDOMNodePtr m_pNode;
m_pNode = m_pDocRoot->firstChild;
_bstr_t ttt = m_pDocRoot->xml;
return 0;
}
建个a.xml,内容如下,注意路径
<?xml version="1.0"?>
<autos>
<manufacturer name="Chevrolet">
<make name="Corvette">
<model>2000 Convertible</model>
<price currency="usd">60,000</price>
<horsePower>420</horsePower>
<fuelCapacity units="gallons">18.5</fuelCapacity>
</make>
</manufacturer>
<manufacturer name="Mazda">
<make name="RX-7">
<model>test model</model>
<price currency="usd">30,000</price>
<horsePower>350</horsePower>
<fuelCapacity units="gallons">15.5</fuelCapacity>
</make>
</manufacturer>
</autos>
运行程序,哈哈,最后ttt里面的内容,断到了吧.
- API 使用 XML的COM组件
- COM组件的使用
- com组件的使用
- COM组件的使用注意事项
- ExecSQLMeta组件API的使用
- ASP使用C#编写的COM+组件
- 编写脚本使用的COM组件
- JavaScript怎样使用COM组件的事件
- Excel——Com组件的使用
- 使用ATL进行com组件的开发
- ASP使用C#编写的COM+组件
- jsp使用com组件
- COM 组件使用注意
- COM组件使用
- com组件 使用小记
- COM组件的使用方法
- COM组件的使用方法
- COM组件的初始化
- log4j使用大全
- .net面试题大全(有答案)
- Windows快捷键
- 个人对应的金庸人物
- fjnu 1142 Error Correction
- API 使用 XML的COM组件
- 实数小数后只保存2位,实现方法
- java 调用命令 备份MYSQL数据库
- 加密算法学习笔记之二__一个完整的加密过程
- 对妹妹的愧疚
- MySql 中文乱码问题,:
- linux软件安装
- A reply from Jeffery Richter
- JBoss Portal and Alfresco integration (集成)