| |

VerySource

 Forgot password?
 Register
Search
View: 564|Reply: 2

Questions about reading XML? ? ? ?

[Copy link]

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-1-22 18:20:01
| Show all posts |Read mode
I have an xml file
  <? xml version = "1.0" standalone = "yes"?>
-<DATAPACKET Version = "2.0">
-<METADATA>
+ <FIELDS>
  <FIELD attrname = "PerUUID" fieldtype = "string.uni" WIDTH = "508" />
  <FIELD attrname = "PerName" fieldtype = "string.uni" WIDTH = "508" />
  <FIELD attrname = "PerSex" fieldtype = "string.uni" WIDTH = "508" />
  <FIELD attrname = "PerAge" fieldtype = "string.uni" WIDTH = "508" />
  <FIELD attrname = "PerJob" fieldtype = "string.uni" WIDTH = "508" />
  <FIELD attrname = "PerRole" fieldtype = "string.uni" WIDTH = "508" />
  <FIELD attrname = "PerMemo" fieldtype = "string.uni" WIDTH = "508" />
  <FIELD attrname = "UPassword" fieldtype = "string.uni" WIDTH = "508" />
  <FIELD attrname = "LoginName" fieldtype = "string.uni" WIDTH = "508" />
  <FIELD attrname = "PerDept" fieldtype = "string.uni" WIDTH = "508" />
  <FIELD attrname = "PrjID" fieldtype = "i4" />
  <FIELD attrname = "DeptID" fieldtype = "string.uni" WIDTH = "508" />
  <FIELD attrname = "DeptName" fieldtype = "string.uni" WIDTH = "508" />
  <FIELD attrname = "DeptMemo" fieldtype = "bin.hex" SUBTYPE = "Text" />
  </ FIELDS>
  <PARAMS />
  </ METADATA>
-<ROWDATA>
  <ROW PerUUID = "001" PerName = "aaa" PerSex = "Male" UPassword = "d41d8cd98f00b204e9800998ecf8427e" LoginName = "aaa" PerDept = "0001" PrjID = "0" DeptID = "0001" DeptName = "wewe" />
  <ROW PerUUID = "002" PerName = "bbb" PerSex = "Male" UPassword = "d41d8cd98f00b204e9800998ecf8427e" LoginName = "bbb" PerDept = "0001" PrjID = "0" DeptID = "0001" DeptName = "wewe" />
  <ROW PerUUID = "003" PerName = "ccc" PerSex = "Male" UPassword = "d41d8cd98f00b204e9800998ecf8427e" LoginName = "ccc" PerDept = "0001" PrjID = "0" DeptID = "0001" DeptName = "wewe" />
  <ROW PerUUID = "004" PerName = "ddd" PerSex = "Male" UPassword = "d41d8cd98f00b204e9800998ecf8427e" LoginName = "ddd" PerDept = "0002" PrjID = "0" DeptID = "0002" DeptName = "qqqq" />
  <ROW PerUUID = "005" PerName = "eee" PerSex = "Male" UPassword = "d41d8cd98f00b204e9800998ecf8427e" LoginName = "eee" PerDept = "0002" PrjID = "0" DeptID = "0002" DeptName = "qqqq" />
  </ ROWDATA>
  </ DATAPACKET>
I want to read all the contents of PerName under <ROWDATA>:
Please master to solve! !! !!
Reply

Use magic Report

0

Threads

8

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-2-3 19:00:01
| Show all posts
Has your document been read in? If it has been read and has reached the node, the following can be achieved
For i = 0 To rootNode.childNodes.length-1
  If rootNode.childNodes (i) .nodeName = "ROWDATA" Then
    for j = 1 to rootNode.childNodes (i) .childNodes (j)
      if rootNode.childNodes (i) .childNodes (j) .nodeName = "ROW" then
         msgbox rootNode.childNodes (i) .getAttribute ("PerName")
      end if
    next j
  end if
next i
Reply

Use magic Report

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

 Author| Post time: 2020-3-26 19:30:01
| Show all posts
if rootNode.childNodes (i) .childNodes (j) .nodeName = "ROW" then '-> Prompt me that the object does not support the property and method
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list