Nп/п : 33 из 37
 От   : Accu Backup                         2:5075/128        18 сен 23 05:32:09
 К    : ObiWan                                                18 сен 23 15:34:03
 Тема : Re: Anyone know how read XML?
----------------------------------------------------------------------------------
                                                                                 
@MSGID:
<5dd23203-d4dc-4ffa-9a17-f2201d506906n@googlegroups.com> 2a290fcd
@REPLY: <20230912151031.000065d2@mvps.org.invalid>
717100bb
@REPLYADDR Accu Backup <accubackup1@gmail.com>
@REPLYTO 2:5075/128 Accu Backup
@CHRS: CP866 2
@RFC: 1 0
@RFC-References:
<0c640188-cdf2-421e-aca2-583457644423n@googlegroups.com> <d0dfac9e-d413-490b-a595-fb2fcde550aan@googlegroups.com>
<24c250df-8e59-4af9-b5bf-d17f6a92a6e4n@googlegroups.com> <20230414171132.00006d23@mvps.org.invalid>
<5cf1be47-7a74-42fa-b012-9e0c167ae58en@googlegroups.com> <1c082c0f-fad1-4a99-834b-22db0cc3c815n@googlegroups.com>
<20230822174909.00004e84@mvps.org.invalid> <d8705cd6-a647-4f5c-92e7-4746e79a5448n@googlegroups.com>
<20230825113749.00003ea6@mvps.org.invalid> <20230825113913.000017cb@mvps.org.invalid>
<877e2be8-725d-4849-9c7c-4ea2adc83303n@googlegroups.com> 1@paganini.bofh.team>
<6aa51ffe-f4a3-46a4-a793-f971c42d26f5n@googlegroups.com> <20230911144702.0000276d@mvps.org.invalid>
<20230912124422.000033dc@mvps.org.invalid> <6090fcee-2f31-4d45-9526-4887f4c2afabn@googlegroups.com>
<20230912150735.000072a1@mvps.org.invalid> <20230912151031.000065d2@mvps.org.invalid>
@RFC-Message-ID:
<5dd23203-d4dc-4ffa-9a17-f2201d506906n@googlegroups.com>
@TZUTC: -0700
@PID: G2/1.0
@TID: FIDOGATE-5.12-ge4e8b94
On Tuesday, September 12, 2023 at 9:10:34 AM UTC-4, ObiWan wrote:
> :: On Tue, 12 Sep 2023 15:07:35 +0200 
> :: (microsoft.public.vb.general.discussion) 
> :: <20230912150...@mvps.org.invalid>
> :: ObiWan <obi...@mvps.org.invalid> wrote: 

> > Yep, my fault, that`s VBA code (aka VB6)
> A suggestion, fetch the code and the sample XML datafile and use those 
> to put together a working VB6 application, then try the application in 
> IDE and set some breakpoints to step through the code and understand 
> how the whole thing works, once you`ll have a grip on on, you may move 
> on and customize the code to deal with your XML data, at that point you 
> will have the code ready to be inserted in your application :)

 Thanks Obi, I finally made progress. I tried this sample and was
able to see it in action. I actually had a copy in my Demo folder
that I apparently tried years ago but wasn`t able to grasp back then.
Now, I was able to follow it and modify it a bit to work with my
XML. A couple of things though...

 1) The sample is using an .xsl file to convert the .xml into
.html. I don`t see in the sample a way to extract the various values so
I am just saving the Parent node and it`s Child nodes in a string.
Then I use the method you posted above to extract that info and store
in my variables. When I have all the values, I read the next Parent
node and repeat. I changed doc.Load(file) to doc.loadXML(mystring) and I
changed doc.selectNodes("/core/worker") to doc.selectNodes("*"). I`m not sure if
this is a good way to get the values from a string.

success = doc.loadXML(mystring)
Set nodeList = doc.selectNodes("*")

If Not nodeList Is Nothing Then
For Each node In nodeList
` Could also do node.attributes.getNamedItem("name").text
name = node.selectSingleNode("@name").Text
source = node.selectSingleNode("@source").Text
description = node.selectSingleNode("@direction").Text
printf name & vbTab & source & vbTab & description


2) When I get to the child nodes...

If node.hasChildNodes Then
For Each child In node.childNodes
name = child.nodeName

 I`m noticing that every other child node name is "#text" (or
something similar... I`m not at the IDE now to check).
 In my case statement, my first test is for that and if so, go to
the next child node. I don`t know how it`s getting "#text" for every
other child node name. Is that normal when loading a string xml?

For Each child In node.childNodes
name = child.nodeName
Select Case LCase(name)
case "#text"
Goto NextCNode
etc.
--- G2/1.0
 * Origin: usenet.network (2:5075/128)
SEEN-BY: 5001/100 5005/49 5015/255 5019/40 5020/715
848 1042 4441 12000
SEEN-BY: 5030/49 1081 5058/104 5075/128
@PATH: 5075/128 5020/1042 4441



   GoldED+ VK   │                                                 │   09:55:30    
                                                                                
В этой области больше нет сообщений.

Остаться здесь
Перейти к списку сообщений
Перейти к списку эх