VC,VB操作XML
TCHAR buffer[MAX_PATH] = {};
::GetModuleFileName(NULL, buffer, MAX_PATH);
CString strPath = buffer;
int nIndex = strPath.ReverseFind(_T('\\'));
strPath = strPath.Left(nIndex + );
CString strBomFile = strPath + _T("Bom.xml"); MSXML2::IXMLDOMDocumentPtr pDocXML = NULL;
MSXML2::IXMLDOMElementPtr pRoot = NULL;
MSXML2::IXMLDOMElementPtr pNode = NULL;
HRESULT hr = pDocXML.CreateInstance(__uuidof(MSXML2::DOMDocument));
ASSERT(SUCCEEDED(hr));
pRoot = pDocXML->createElement((_bstr_t)(_T("BomData")));
pDocXML->appendChild(pRoot);
//3-1、遍历BomRcdArr
for(long i = ;i<;i++)
{ CString strFilePath = strBomFile; //write to xml
short iNum=;
iNum=;
BSTR strKey;
BSTR strValue;
short ii=; for (ii=;ii<iNum;ii++)
{
strKey = L"KEY";
strValue =L"VALUE";
//pITHDbBomRecorder->GetItem(&strKey,&strValue,ii); pNode=NULL;
pNode = pDocXML->createElement((_bstr_t)(_T("Node")));
pNode->put_text((_bstr_t)_T("BomData"));//设置标签的文本内容; pNode->setAttribute((_bstr_t)_T("BomDataBigNum"),(_variant_t)i);
pNode->setAttribute((_bstr_t)_T("BomDataSmallNum"),(_variant_t)ii);
pNode->setAttribute((_bstr_t)_T("key"),(_variant_t)strKey);
pNode->setAttribute((_bstr_t)_T("value"),(_variant_t)strValue); pRoot->appendChild(pNode); } }
pDocXML->save( _bstr_t(strBomFile));
pNode->Release();
pRoot->Release();
pDocXML->Release();
Private Sub Command1_Click()
Dim xDoc As Object
Dim xmlFile As String
Dim strWidth As String
Dim strHeight As String
Set xDoc = CreateObject("MSXML2.DOMDocument")
xmlFile = "C:\aa.xml"
xDoc.Load xmlFile
strWidth = xDoc.selectSingleNode("overlays").selectSingleNode("Info").Attributes().Text
strHeight = xDoc.selectSingleNode("overlays").selectSingleNode("Info").Attributes().Text
MsgBox ("Width=" & strWidth & " Height=" & strHeight)
xDoc.selectSingleNode("overlays").selectSingleNode("Info").Attributes().Text = ""
xDoc.selectSingleNode("overlays").selectSingleNode("Info").Attributes().Text = ""
xDoc.save (xmlFile)
End Sub 注意 你上面的XML中Width=""Height="" 要分开,改成:
Width="" Height=""
VC,VB操作XML的更多相关文章
- VC++中操作XML(MFC、SDK)转
[转]VC++中操作XML(MFC.SDK) XML在Win32程序方面应该没有在Web方面应用得多,很多Win32程序也只是用XML来存存配置信息而已,而且没有足够的好处的话还不如用ini.VC++ ...
- [转]VC++中操作XML(MFC、SDK)
XML在Win32程序方面应该没有在Web方面应用得多,很多Win32程序也只是用XML来存存配置信息而已,而且没有足够的好处的话还不如用ini.VC++里操作XML有两个库可以用:MSXML和Xml ...
- VC++中操作XMLWin32实例
摘要:VC++中操作XML XML在Win32程序方面应该没有在Web方面应用得多,很多Win32程序也只是用XML来存存配置信息而已,而且没有足够的好处的话还不如用ini.VC++里操作XML有两个 ...
- Asp.Net 操作XML文件的增删改查 利用GridView
不废话,直接上如何利用Asp.NET操作XML文件,并对其属性进行修改,刚开始的时候,是打算使用JS来控制生成XML文件的,但是最后却是无法创建文件,读取文件则没有使用了 index.aspx 文件 ...
- VB操作EXCEL文件
用VB操作Excel(VB6.0)(整理) 首先创建Excel对象,使用ComObj:Dim ExcelID as Excel.ApplicationSet ExcelID as new Excel. ...
- php中通过DOM操作XML
DOM文档在js里早就接触过,知道DOM不但可以操作html文档,还可以操作XHTML,XML等文档,有着极强的通用性,下面我们通过两个小例子,看看在PHP中是如何用DOM操作XML文档的,和js中差 ...
- 使用dom4j操作XML
DOM4J介绍 DOM4J是使用Java语言编写的,用于读写及操作XML的一套组件,DOM4J同时具有DOM修改文件的优点和SAX读取快速的优点. DOM4J的使用 首先下载dom4j的JAR包,我用 ...
- 使用JDOM操作XML
JDOM介绍 JDOM是使用Java语言编写的,用于读写及操作XML的一套组件,Jdom同时具有DOM修改文件的优点和SAX读取快速的优点. JDOM的使用 首先下载JDOM的JAR包,本文使用的是j ...
- php : DOM 操作 XML
DOM 操作 XML 基本用法 XML文件: person.XML <?xml version="1.0" encoding="utf-8" ?> ...
随机推荐
- linux crontab定时任务不执行
如crontab 没有成功,检测crontab 服务是否启动, /etc/init.d/crond status 查看crond状态 /etc/init.d/crond restart 重启crond ...
- 8种提升ASP.NET Web API性能的方法
英文原文:8 ways to improve ASP.NET Web API performance ASP.NET Web API 是非常棒的技术.编写 Web API 十分容易,以致于很多开发者没 ...
- 基于Asp.net C#实现HTML转图片(网页快照)
一.实现方法 //WebSiteThumbnail.cs文件,在BS项目中需要添加对System.Windows.Forms的引用 using System; using System.Data; u ...
- zepto.min.js
/* Zepto v1.1.3 - zepto event ajax form ie - zeptojs.com/license */var Zepto=function(){function L(t ...
- hdu 2815 Mod Tree (exBSGS)
http://acm.hdu.edu.cn/showproblem.php?pid=2815 //解 K^D ≡ N mod P #include<map> #include<cma ...
- 【十】虚拟机工具 03 - jinfo命令使用
guchunchaodeMacBook-Air:workspaces guchunchao$ jinfo Usage: jinfo [option] <pid> (to connect ...
- 【LDAP】LDAP注入漏洞与防御
0x01 前言 前两天爆了一个LDAP漏洞,据说存在了8年现在才被发现,感概一下,不知这8年来有多少站被搞了... 想着复现这个漏洞,就先复习一下LDAP注入的相关知识吧,差了很多资料,记一下笔记. ...
- 为什么要用日志框架 Logback 基本使用
[日志框架]以时间为单位描述应用项目运行状态:用户下线.接口超时.数据库崩溃等等一系列事件 [日志框架能力] 1.定制输出格式 2.定制输出目标 3.携带 Context 比如 HelloWorld. ...
- Atlassian - Confluence Security Advisory - 2019-03-20
-------------------- This problem refers to the advisory found at https://confluence.atlassian.com/d ...
- Kaldi中的L2正则化
steps/nnet3/train_dnn.py --l2-regularize-factor 影响模型参数的l2正则化强度的因子.要进行l2正则化,主要方法是在配置文件中使用'l2-regulari ...