Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

foreach - xml

Closed Thread
 
Thread Tools Display Modes
Old 01-10-2008   #1 (permalink)
NeilOz
Guest


 

foreach - xml

Basically at the moment I've got it appending the out put to a file, Ideally
what I would like it to do is to store each of the results in a string. I've
tried as many ways as I could think of doing it but I'm stumped.. any help
would be appreciated.

foreach ($Code in $Securities)
{
$Quote =
[xml]$webclient.DownloadString("http://server:1891/MarketInfoService.asmx/LiveQuote?Code=" + $Code[0])
$Quote.Quote | format-list | Out-File -filepath "d:\test.txt" -Append
}
Old 01-10-2008   #2 (permalink)
Marco Shaw [MVP]
Guest


 

Re: foreach - xml

NeilOz wrote:
Quote:

> Basically at the moment I've got it appending the out put to a file, Ideally
> what I would like it to do is to store each of the results in a string. I've
> tried as many ways as I could think of doing it but I'm stumped.. any help
> would be appreciated.
>
> foreach ($Code in $Securities)
> {
> $Quote =
> [xml]$webclient.DownloadString("http://server:1891/MarketInfoService.asmx/LiveQuote?Code=" + $Code[0])
> $Quote.Quote | format-list | Out-File -filepath "d:\test.txt" -Append
> }
Not sure I follow, but you could try doing this:

$string="" (before your function)
....
$string+=$quote.quote (to replace the last line above in your function)

Then $string should have the results.

You're sure you want a string, and not an array?

Array:
$array=@() (before your function)
....
$array+=$quote.quote (to replace the last line above in your function)

Then $array should have the results. Use $array[0] to get the first line.


--
Microsoft MVP - Windows PowerShell
http://www.microsoft.com/mvp

PowerGadgets MVP
http://www.powergadgets.com/mvp

Blog:
http://marcoshaw.blogspot.com
Closed Thread

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Export-CSV and foreach Ryan PowerShell 6 05-29-2007 06:16 AM
foreach, foreach-object & begin/process/end scriptblock clauses... Clint Bergman PowerShell 12 05-16-2007 05:30 PM
Difference in semantics of for, foreach and foreach-object Andrew Watt [MVP] PowerShell 3 01-26-2007 12:46 PM
possible bug with using the $foreach keyword inside foreach loops.. klumsy@gmail.com PowerShell 6 11-16-2006 06:50 PM
RC2 - Bug in help for foreach Andrew Watt [MVP] PowerShell 1 09-27-2006 05:22 PM








Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50