VB读取XML文件,lectNodes获取节点属性

更新时间:2023-07-27 02:58:20 阅读: 评论:0

baci什么意思VB读取XML⽂件,lectNodes获取节点属性VB读取XML⽂件,通过lectNodes,lectSingleNode获取 XML⽂件节点内容,将获取的内容赋值给类的属性。
被读取的:
1<?xml version="1.0" encoding="utf-8"?>
2<issues total_count="1" offt="0" limit="25" type="array">
tospo3    <issue>
4        <id>3344</id>
5        <project id="49" name="text xml" />
6        <tracker id="9" name="⽀持" />
7        <status id="5" name="已确认" />
8        <priority id="2" name="普通" />
9        <author id="34" name="author1" />
10        <assigned_to id="34" name="author1" />
11        <subject>test1-⽀持任务第⼀个</subject>
12        <description></description>
13        <start_date>2015-04-01</start_date>
14        <due_date>2015-04-07</due_date>
15        <done_ratio>100</done_ratio>
16        <is_private>fal</is_private>
17        <estimated_hours>8.0</estimated_hours>
18        <custom_fields type="array">
19            <custom_field id="3" name="作业者">
20                <value>34</value>
21            </custom_field>
22            <custom_field id="4" name="确认者">
23                <value>14</value>
24            </custom_field>
25        </custom_fields>
26        <created_on>2015-04-10T02:23:23Z</created_on>
27        <updated_on>2015-04-27T05:54:31Z</updated_on>
28        <clod_on>2015-04-10T07:29:58Z</clod_on>
29    </issue>
30</issues>
vb读⼊代码:
1Public Function getIssuesCollection() As Collection
2    Set xdoc = CreateObject("Microsoft.XMLDOM")
3 '异步标志(true时,不等待xml⽂件读⼊完成,直接执⾏后续代码;fal时,等待xml⽂件读⼊完成后,再执⾏后续代码)
4 xdoc.async = Fal广州英语
5    xdoc.Load ("E:\l")
6    Set issues = xdoc.SelectNodes("issues/issue")
7
8    For Each issue In issues
9        Set crtIssue = New cls_Issue
10        crtIssue.IssueId = issue.SelectSingleNode("id").Text
11        crtIssue.ProjectId = issue.SelectSingleNode("project").Attributes.Item(0).Text
12        crtIssue.ProjectName = issue.SelectSingleNode("project").Attributes.Item(1).Text
13        crtIssue.TrackerName = issue.SelectSingleNode("tracker").Attributes.Item(1).Text
14        crtIssue.Status = issue.SelectSingleNode("status").Attributes.Item(1).Text
15        crtIssue.Priority = issue.SelectSingleNode("priority").Attributes.Item(1).Text
雷米封奋斗英文16        crtIssue.Author = issue.SelectSingleNode("author").Attributes.Item(1).Text
17        If Not issue.SelectSingleNode("assigned_to") Is Nothing Then
18            crtIssue.Assigned_to = issue.SelectSingleNode("assigned_to").Attributes.Item(1).Text
19        End If
20        crtIssue.Subject = issue.SelectSingleNode("subject").Text
21        crtIssue.StartDate = issue.SelectSingleNode("start_date").Text
22        crtIssue.DueDate = issue.SelectSingleNode("due_date").Text
23
24        If Not issue.SelectSingleNode("estimated_hours") Is Nothing Then
25            crtIssue.Estimated_hours = issue.SelectSingleNode("estimated_hours").Text
26        End If
27        If Not issue.SelectSingleNode("done_ratio") Is Nothing Then
28            crtIssue.Done_ratio = issue.SelectSingleNode("done_ratio").Text
29        End If
东方娃娃怎么样30        If Not issue.SelectSingleNode("parent") Is Nothing Then
31            crtIssue.ParentId = issue.SelectSingleNode("parent").Attributes.Item(0).Text
32        End If
33
34        Set custom_fields = issue.SelectNodes("custom_fields/custom_field")
35        For Each custom_field In custom_fields
36            'when  id is ur checkedlike a bird
37            If checked_custom_fields.Exists(custom_field.Attributes.Item(0).Text) Then
38                Set cfield = checked_custom_fields.Item(custom_field.Attributes.Item(0).Text)
39                Set cloneCfield = cfield.clone
itemno是什么意思40                cloneCfield.value = custom_field.Text
41                ' to add id/cField
42                crtIssue.mCustomFields.Add custom_field.Attributes.Item(0).Text, cloneCfield
matthew43                'Debug.Print cfield.value
44            End If
45        Next
46
47        allIssues.Add crtIssue
48    Next
rice49
50End Function

本文发布于:2023-07-27 02:58:20,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/90/189912.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:获取   节点   后续   代码   属性   内容   赋值   读取
相关文章
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图