VB 操作XML 问题
<?xml version="1.0" encoding="UTF-8" ?>
- <task guid="00000123460E9E684DF1EC79F8E7683B" title="基础数据" description="采集基础数据" version="2" instanceGuid="9C7FDC8A500E4C668A4E505285153F69" mode="1" stage="1" status="2" defineOrgCode="103" defineOrgName="人民检察院" canAllOrgLoad="true" taskType="0" defineOrgGuid="000001261CB23C6276340034E765AB65" taskMakerCode="admin" taskMakerGuid="97979797000000000000000000000000">
<allowLoadOrgs />
- <businessTasks>
- <baseDataTask name="baseDataTask" title="基础数据任务">
- <tables>
- <table name="JC_AssetPlace" title="存放地点" tableType="0" tailSql="">
<dataFilePath />
<dataFilePath1 />
+ <columns>
<column name="OverDueTime" title="截止时间" scale="0" size="0" dataType="4" />
<column name="OrgID" title="组织ID" scale="0" size="0" dataType="4" />
<column name="RwVrsn" title="行版本" scale="0" size="0" dataType="4" />
<column name="Creater" title="创建人" scale="0" size="30" dataType="10" />
<column name="Description" title="说明" scale="0" size="255" dataType="10" />
<column name="CreateDate" title="创建日期" scale="0" size="0" dataType="6" />
<column name="ObjID" title="ObjID" scale="0" size="0" dataType="4" />
<column name="ZTYear" title="帐套年度标识" scale="0" size="0" dataType="4" />
<column name="OrgGuid" title="组织ID" scale="0" size="38" dataType="10" />
</columns>
</table>
+ <table name="JC_BM" title="部门" tableType="0" tailSql="">
<dataFilePath />
<dataFilePath1 />
- <columns>
<column name="PrntCode" title="父码" scale="0" size="60" dataType="10" />
<column name="ObjID" title="ObjID" scale="0" size="0" dataType="4" />
<column name="OrgFax" title="传真" scale="0" size="30" dataType="10" />
<column name="IndustryTypeId" title="行业类别Id" scale="0" size="15" dataType="4" />
<column name="StdCode" title="部门代码" scale="0" size="50" dataType="10" />
<column name="RwID" title="行ID" scale="0" size="0" dataType="4" />
<column name="EcoTypeId" title="经济类型Id" scale="0" size="15" dataType="4" />
<column name="ZtYear" title="年度标识" scale="0" size="0" dataType="4" />
<column name="StartFlag" title="是否启用" scale="0" size="0" dataType="0" />
<column name="ModifyDate" title="上次修改日期" scale="0" size="0" dataType="6" />
</columns>
</table>
- <table name="JC_ZY" title="人员" tableType="0" tailSql="">
<dataFilePath />
<dataFilePath1 />
+ <columns>
<column name="Attribute" title="职员属性" scale="0" size="255" dataType="10" />
<column name="StartFlag" title="是否启用" scale="0" size="0" dataType="0" />
<column name="ZTYear" title="帐套年度标识" scale="0" size="0" dataType="4" />
</columns>
</table>
</tables>
</baseDataTask>
1。怎么修改<dataFilePath /> 的内容啊?
<table name="JC_AssetPlace" title="存放地点" tableType="0" tailSql="">
<dataFilePath />
<dataFilePath1 />
2.修改根节点的属性值怎么修改?
<task guid="00000123460E9E684DF1EC79F8E7683B" title="基础数据" description="采集基础数据" version="2" instanceGuid="9C7FDC8A500E4C668A4E505285153F69" mode="1" stage="1" status="2" defineOrgCode="103" defineOrgName="人民检察院" canAllOrgLoad="true" taskType="0" defineOrgGuid="000001261CB23C6276340034E765AB65" taskMakerCode="admin" taskMakerGuid="97979797000000000000000000000000">
[解决办法]
学习UPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUP
[解决办法]
用msxml库。
xpath获得结点。
[解决办法]
http://msdn.microsoft.com/en-us/library/aa468547.aspx
[解决办法]
http://www.w3school.com.cn/xmldom/index.asp
[解决办法]
这两天没功夫弄xml,关注,帮顶!:)
[解决办法]
DCOM.........
[解决办法]
DOM.............
[解决办法]
都没说明白,不过我搞定了,不过有点麻烦,不知道有没有更好的办法了
Dim xml_document As DOMDocument
Dim values_node As IXMLDOMNode
Set xml_document = New DOMDocument
xml_document.Load appPath & "7za" & XMLFileName
If xml_document.documentElement Is Nothing Then
frmDataExport.List1.AddItem "未找到任务文件", 0
Exit Sub
End If
Set values_node = xml_document.selectSingleNode("task") '根节点
'//XML文件头属性信息
values_node.Attributes.getNamedItem("guid").text = Replace$(Replace$(Replace$(OrgGuid, "-", ""), "{", ""), "}", "")
For I = 0 To values_node.childNodes.Length - 1
For J = 0 To values_node.childNodes.Item(I).childNodes.Length - 25 '循环二级子节点 获取单据任务
If values_node.childNodes.Item(I).childNodes(J).Attributes.getNamedItem("title").text = "基础数据任务" Or values_node.childNodes.Item(I).childNodes(J).Attributes.getNamedItem("title").text = "组织机构任务" Or values_node.childNodes.Item(I).childNodes(J).Attributes.getNamedItem("title").text = "单据任务" Then
For K = 0 To values_node.childNodes.Item(I).childNodes(J).childNodes.Length - 1
For L = 0 To values_node.childNodes.Item(I).childNodes(J).childNodes(K).childNodes.Length - 1
'Debug.Print values_node.childNodes.Item(I).childNodes(J).childNodes(K).nodeName
For m = 0 To values_node.childNodes.Item(I).childNodes(J).childNodes(K).childNodes(L).childNodes.Length - 3
'Debug.Print values_node.childNodes.Item(I).childNodes(J).childNodes(K).childNodes(L).childNodes(m).nodeName
If values_node.childNodes.Item(I).childNodes(J).childNodes(K).childNodes(L).Attributes.getNamedItem("name").text = "GD_AssetCard_I" Then Exit For
'Debug.Print values_node.childNodes.Item(I).childNodes(J).childNodes(K).childNodes(L).Attributes.getNamedItem("name").text
Select Case values_node.childNodes.Item(I).childNodes(J).childNodes(K).childNodes(L).Attributes.getNamedItem("title").text
Case "部门"
values_node.childNodes.Item(I).childNodes(J).childNodes(K).childNodes(L).childNodes.Item(m).text = "JC_BM" & Format(Date, "yyyymmdd") & ".DATA"
Case "人员"
values_node.childNodes.Item(I).childNodes(J).childNodes(K).childNodes(L).childNodes.Item(m).text = "JC_ZY" & Format(Date, "yyyymmdd") & ".DATA"
Case "组织机构"
values_node.childNodes.Item(I).childNodes(J).childNodes(K).childNodes(L).childNodes.Item(m).text = "Sys_OrgUnit" & Format(Date, "yyyymmdd") & ".DATA"
Case "固定资产卡片表头表"
values_node.childNodes.Item(I).childNodes(J).childNodes(K).childNodes(L).childNodes.Item(m).text = "GD_AssetCard_H" & Format(Date, "yyyymmdd") & ".DATA"
values_node.childNodes.Item(I).childNodes(J).childNodes(K).childNodes(L).childNodes.Item(m + 1).text = "GD_AssetCard_H_Update" & Format(Date, "yyyymmdd") & ".DATA"
End Select
Next
Next
Next
End If
Next
Next
xml_document.Save appPath & "JQdataPack" & Format(Date, "yyyymmdd") & ".xml"
[解决办法]
看了半天,终于看明白了,我也在学
[解决办法]
null