Re: Reading Reults of txt file - and then...

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Today (ex)
Date: 02/21/05


Date: Mon, 21 Feb 2005 07:54:30 -0800

Thanks for the reply Al, I need it to execute another file if it finds
that the first line exists and then the second line tells me what it is
that I need to execute, well not exactly, but I can evaluate it to get
the right info to launch what I need. The problem, as I see it, is that
the length between the two statements will not be the same, and the XML
file does not appear to have any CR's in Notepad.

On the MSFT script center I found a script to take a txt file and run it
backwards, which would work, but when I put it in my vbs it just seemed
to launch an endless loop, CPU went to 100% and I had to kill the process.

The file I am reading is the Results.xml file from the MSFT FEB EST. I
have a few hundred people who are still not part of SMS and several
regional offices that need to be patches for 004, 006, 009 and I do this
in a vbs every month.

Here is an example of the output:

- <ScanResults>
   <ScanDateTime>2/20/2005 11:31:21 AM</ScanDateTime>
   <XMLDataVersion>2005.2.20.0</XMLDataVersion>
   <ScannedBy>ANCHOR \ SYSTEM</ScannedBy>
- <Machine>
   <MachineName>ANCHOR</MachineName>
   <Domain>AVWORLD</Domain>
- <Product>
   <ProductName>.NET FRAMEWORK 1.1 SP1</ProductName>
- <Item>
   <LocaleID>1033</LocaleID>
   <ItemClass>Patch</ItemClass>
   <BulletinID>MS05-004</BulletinID>
   <BulletinTitle>Vulnerability in ASP.Net May Lead to Authentication
Bypass</BulletinTitle>
   <SQNumber>886903</SQNumber>
 
<BulletinUrl>http://www.microsoft.com/technet/security/bulletin/MS05-004.mspx>

 
<DownloadURL>
http://download.microsoft.com/download/E/1/4/E14C0C02-591B-4696-8552-EB710C26A3CD/NDP1.1sp1-KB886903-X86.exe>

   <PatchName />
   <Description />
   <Status>Installed</Status>
   <ItemType />
   <DatePosted />
   <DateRevised />
   <UnattendSyntax>/q</UnattendSyntax>
   </Item>
   </Product>
- <Product>
   <ProductName>WINDOWS MESSENGER 4.7.0.2009</ProductName>
- <Item>
   <LocaleID>1033</LocaleID>
   <ItemClass>Patch</ItemClass>
   <BulletinID>MS05-009</BulletinID>
   <BulletinTitle>Vulnerability in PNG Processing Could Lead to Buffer
Overrun</BulletinTitle>
   <SQNumber>887472</SQNumber>
 
<BulletinUrl>
http://www.microsoft.com/technet/security/bulletin/MS05-009.mspx>

 
<DownloadURL>
http://download.microsoft.com/download/c/8/5/c851bf78-0907-4fc7-ae1b-1b9c4fb1474d/WindowsMessenger-KB887472-PreXPSP2-ENU.exe>

   <PatchName />
   <Description />
   <Status>Installed</Status>
   <ItemType />
   <DatePosted />
   <DateRevised />
   <UnattendSyntax>/q /norestart</UnattendSyntax>
   </Item>
   </Product>
   </Machine>
   <Comments />
   </ScanResults>

As you can see the <status> is listed after the bulleting ID and Product
name.

Al Dunbar [MS-MVP] wrote:
> "Today" <ex> wrote in message news:eMidndtAa_y0aYXfRVn-pQ@adelphia.com...
>
>>I am using FSO to read a XML file, using the ReadAll method. I have a
>>couple of questions. First how does an XML file appear to wsh?
>
>
> What WSH sees of it through the File System Object is a text file.
>
>
>> Is it
>>one silgle line like in Notepad or is there several lines like when
>>displayed in IE?
>
>
> Notepad will likely do a better job of showing you how the XML file is
> actually formatted with newline characters and other whitespace.
>
>
>> If it is seperate lines I can use the readline to get
>>what I need,
>
>
> What is it that you actually need?
>
>
>> if it is diplayed with no CR's then I don't think that
>>method will work. I am using ReadAll and I can find the data I want but
>>then if the data is found I need to then read data before it, as an
>
> example:
>
>><services>test</services>
>>
>>Is what I am looking for first, and if this text exists I then need to
>>go backwards and look for
>>
>><process>ten</process>.
>>
>>The data length between these two can vary for each instance within the
>>file, where some other data may be <asdf>fkjshdfkjhksjdfh</asdf> for one
>>instance, and for another it may be <asd>adf</asd>.
>
>
> Once you have found these tags (or not, depending on whether or not they are
> present), what will your script do - just report its success? Or will you
> then need to perform some other XML-type manipulations of some sort?
>
> Assuming that you just need to determine whether or not the services tag
> exists and is preceded by the process tag, and assuming that these tags will
> be EXACTLY as you have shown them in the XML data stream, I would tend to
> use readall, with logic along these lines:
>
> services = "<services>test</services>"
> process = "<process>ten</process>"
> xms = whatever.readall
> findservices = instr( 1, xms, services, vbtextcompare )
> if ( findservices = 0 ) then
> wscript.echo "did not find " & services
> else
> findprocess = instr( 1, xms, process, vbtextcompare )
> if ( findprocess = 0 ) then
> wscript.echo "found " & services & " but not " & process
> elseif ( findprocess > findservices ) then
> wscript.echo services & " NOT preceded by " & process
> else
> wscript.echo services & " IS preceded by " & process
> end if
> end if
>
>
> If you need to perform XML-compliant operations on an XML file, I would
> recommend that you use an XML-specific object instead of FSO.
>
>
> /Al
>
>
>



Relevant Pages

  • Re: Reading Reults of txt file - and then...
    ... > I am using FSO to read a XML file, using the ReadAll method. ... First how does an XML file appear to wsh? ... Once you have found these tags (or not, depending on whether or not they are ...
    (microsoft.public.scripting.vbscript)
  • Re: How Do I search an XML File?
    ... If the XML file is well-formed and the data structure is stable, you could read the file in using the scriptlet library filesystemobject in Access 2000; look up createfileobject for some code examples. ... Or, you can use the old dos style file open, read the file in a line at a time, look for the tags that encapsulate the content you want, pop that information into an array, then deal with the 'hits' after you have completed your line by line scan of the file. ... or is the skill a child node of the employee? ... I also need to scan for the employee skill set if it matches a certain ...
    (microsoft.public.access.externaldata)
  • newbie: how to change webpage element dynamically
    ... I need to come up with a way so that when this xml file is opened up ... say class2, the text in between the value tags must change to class2 ... This code will let me display a drop down menu, ... take the selected value and change the text in the value tags. ...
    (comp.lang.javascript)
  • Re: xml to text ???
    ... You can Loadyour text file into an XmlDocument, ... That strips out all of the tags, ... For example, given this XML file, ... XmlDocument doc = new XmlDocument; ...
    (microsoft.public.dotnet.xml)
  • Re: multiline regular expression (replace)
    ... I would like to perform regular expression replace (e.g. removing ... everything from within tags in a XML file) with multiple-line pattern. ... Another is to use \n in your strings to represent newlines. ...
    (comp.lang.python)