I have an xml file that I need to read using a script.

Here is a snippet of what the file is in notepad:

<property name="slotInfo0902" caption="PCI Slot 2" value="Available"/>
</structure> </category> <category name="architecture"
caption="Architecture">

I need to search for "PCI Slot 2" or whatever slot number it may be,
and return Slot number and the value cleanly like "Slot 2 = Available".
The problem that I am encountering is that the search string is
returned in a different character position everytime I run the script,
so I can't do a

ObjSFile.Write trim(mid(strPCI, 39, 49) & " = " mid(strPCI,58,67))
Any thoughts?

Re: InStr Readline trim? by Steve

Steve
Fri Jan 07 07:27:41 CST 2005

bmills123 wrote:

> I have an xml file that I need to read using a script.
>
> Here is a snippet of what the file is in notepad:
>
> <property name="slotInfo0902" caption="PCI Slot 2" value="Available"/>
> </structure> </category> <category name="architecture"
> caption="Architecture">
>
> I need to search for "PCI Slot 2" or whatever slot number it may be,
> and return Slot number and the value cleanly like "Slot 2 = Available".
> The problem that I am encountering is that the search string is
> returned in a different character position everytime I run the script,
> so I can't do a
>
> ObjSFile.Write trim(mid(strPCI, 39, 49) & " = " mid(strPCI,58,67))
> Any thoughts?

1. Load the file into a DOMDocument object and use DOM methods to locate
the information.

MSXML DOM Reference
http://msdn.microsoft.com/library/en-us/xmlsdk/html/dom_reference.asp

2. If you want to access the the file as a string, use a Regular Expression
to search for patterns.

Introduction to Regular Expressions
http://msdn.microsoft.com/library/en-us/script56/html/reconintroductiontoregularexpressions.asp

--
Steve

An economist is an expert who will know tomorrow why the things he
predicted yesterday didn't happen today. -Laurence J. Peter

Re: InStr Readline trim? by mayayana

mayayana
Fri Jan 07 08:21:37 CST 2005

It can't be in a different position each time
in the same file. You mean that you can't predict the
offset across files? You can use InStr to find it:

Dim s1, s2, Pt1, Pt2
s1 = ="PCI Slot 2"
s2 = "/" '-- or use ">" if necessary.

Pt1 = InStr(1, sFile, s1, 1)
if (Pt1 > 0) then
Pt2 = InStr(Pt1, sFile, s2)
if (Pt2 > 0) then
WhatYoureAfter = Mid(sFile, Pt1, (Pt2 - Pt1))
end if
end if

That should return:
PCI Slot 2" value="Available"

You may need to clean up some quote marks.
--
_____________________________

mayayXXana1a@mindYYspring.com
For return email remove XX and YY.
_____________________________
bmills123 <pha3drus@prodigy.net> wrote in message
news:1105051707.641726.9370@z14g2000cwz.googlegroups.com...
> I have an xml file that I need to read using a script.
>
> Here is a snippet of what the file is in notepad:
>
> <property name="slotInfo0902" caption="PCI Slot 2" value="Available"/>
> </structure> </category> <category name="architecture"
> caption="Architecture">
>
> I need to search for "PCI Slot 2" or whatever slot number it may be,
> and return Slot number and the value cleanly like "Slot 2 = Available".
> The problem that I am encountering is that the search string is
> returned in a different character position everytime I run the script,
> so I can't do a
>
> ObjSFile.Write trim(mid(strPCI, 39, 49) & " = " mid(strPCI,58,67))
> Any thoughts?
>



Re: InStr Readline trim? by bmills123

bmills123
Fri Jan 07 13:33:03 CST 2005

That works. Thank you!