如何在PowerShell中读取ATOM XML



如何从PowerShell调用System.ServiceModel.Syndication.SyndicationFeed?

试图从Powershell读取RSS提要,并且需要遍历提要,我想知道有什么方法可以做到这一点?

我找不到任何关于它的例子。

提前感谢!!拉马尼

你真正想做的是用PowerShell解析XML。 这一个行将让你从这个问题中得到条目:

((New-Object Net.Webclient).DownloadString("http://stackoverflow.com/feeds/question/10589059") -as [xml]).feed.entry

它创建一个新的Web客户端,并下载URL,将其转换为XML,然后只是点到XML元素中(就像在PowerShell中所做的那样)。

这是一个非常简单的衬里,包含了PowerShell的强大功能。 一个类似的例子是Bruce Payette的"PowerShell In Action"的开头。

希望这有帮助

这是我在几秒钟内想到的:

$url = "http://stackoverflow.com/feeds/question/10589059"
[System.Reflection.Assembly]::LoadWithPartialName("System.ServiceModel") | Out-Null
[System.ServiceModel.Syndication.SyndicationFeed] $feed = [System.ServiceModel.Syndication.SyndicationFeed]::Load([System.Xml.XmlReader]::Create($url))
$feed | Get-Member

最新更新