---
title: "PowerShell 脚本读取 rss 新闻"
author: "vv_1024"
date: "2010-02-10T13:22:15Z"
tags: [".net", "PowerShell", "Windows", "XML", "脚本"]
categories: ["操作系统"]
slug: "powershell-rss"
draft: false
lastmod: "2010-02-10T13:33:52Z"
id: 592695
url: "https://lovephoenix.iteye.com/blog/592695"
---

Windows 7 中的PowerShell 脚本很强大，可以直接使用COM组件和.Net类。下面是语音播报热点新闻。

 

```
$sapi = New-Object -Com Sapi.SpVoice
$WebClient = New-Object System.Net.WebClient
#$WebClient.Encoding=[System.Text.Encoding]::GBK
$rss = [XML]($WebClient.DownloadString("http://news.163.com/special/00011K6L/rss_newstop.xml"))
foreach($item in $rss.rss.channel.Item){
    $title = $item.title.InnerText
    $content = $item.description.InnerText.Replace("&nbsp","")
    $title
    $sapi.Speak($title)
    $content
    $sapi.Speak($content + "     ")
}
```