In vbscript, how can I get a collection of the Name in the xml file. I need
to grab x number of entries.

<PC>

<Number="9" Name="EXP061509"/>

<Number="22" Name="EXP061522"/>

</PC>

Re: get xml field by Ato

Ato
Thu Apr 07 20:17:03 CDT 2005

A couple of notes first:
(1) The closest thing to a custom collection in VBScript is the dictionary
(which is basically an associate array)
(2) I think your XML file is "malformed" since the individual child nodes
do not have node names.
It probably should look like this way:
<PC>
<ITEM Number="9" Name="EXP061509"/>
<ITEM Number="22" Name="EXP061522"/>
</PC>

With that taken cared of, try the following snippet
(which assumes your XML stream is in a file called "PC.XML":
'------------------------------------------------------------
xmlFileName = "PC.XML"
Set coll = CreateObject("Scripting.Dictionary")

Set doc = CreateObject("Msxml.DOMDocument")
doc.load(xmlFileName)
set root = doc.documentElement
For each item in root.childNodes
coll.Add item.getattribute("Number"), item.GetAttribute("Name")
Next

Wscript.echo coll("9") '<-- displays "EXP061509"
Wscript.echo coll("22") '<-- displays"EXP061522"


"Big D" <BigDaddy@newsgroup.nospam> wrote in message
news:eyhIrI8OFHA.3788@tk2msftngp13.phx.gbl...
> In vbscript, how can I get a collection of the Name in the xml file. I
need
> to grab x number of entries.
>
> <PC>
>
> <Number="9" Name="EXP061509"/>
>
> <Number="22" Name="EXP061522"/>
>
> </PC>
>
>



Re: get xml field by Ato

Ato
Thu Apr 07 21:15:05 CDT 2005

I meant to say "associative array" (as in PERL)

"Ato Bisda" <atobisda@gmail.com> wrote in message
news:uRM7M39OFHA.248@TK2MSFTNGP15.phx.gbl...
> A couple of notes first:
> (1) The closest thing to a custom collection in VBScript is the
dictionary
> (which is basically an associate array)
> (2) I think your XML file is "malformed" since the individual child nodes
> do not have node names.
> It probably should look like this way:
> <PC>
> <ITEM Number="9" Name="EXP061509"/>
> <ITEM Number="22" Name="EXP061522"/>
> </PC>
>
> With that taken cared of, try the following snippet
> (which assumes your XML stream is in a file called "PC.XML":
> '------------------------------------------------------------
> xmlFileName = "PC.XML"
> Set coll = CreateObject("Scripting.Dictionary")
>
> Set doc = CreateObject("Msxml.DOMDocument")
> doc.load(xmlFileName)
> set root = doc.documentElement
> For each item in root.childNodes
> coll.Add item.getattribute("Number"), item.GetAttribute("Name")
> Next
>
> Wscript.echo coll("9") '<-- displays "EXP061509"
> Wscript.echo coll("22") '<-- displays"EXP061522"
>
>
> "Big D" <BigDaddy@newsgroup.nospam> wrote in message
> news:eyhIrI8OFHA.3788@tk2msftngp13.phx.gbl...
> > In vbscript, how can I get a collection of the Name in the xml file. I
> need
> > to grab x number of entries.
> >
> > <PC>
> >
> > <Number="9" Name="EXP061509"/>
> >
> > <Number="22" Name="EXP061522"/>
> >
> > </PC>
> >
> >
>
>