4
我試圖使用PowerShell來讀取RSS提要,我不能進PowerShell的解析
這裏中提取CDATA段是飼料的片段(與切割成幾個項目節省空間):
<item rdf:about="http://philadelphia.craigslist.org/ctd/blahblah.html">
<title>
<![CDATA[2006 BMW 650I,BLACK/BLACK/SPORT/AUTO ]]>
</title>
...
<dc:title>
<![CDATA[2006 BMW 650I,BLACK/BLACK/SPORT/AUTO ]]>
</dc:title>
<dc:type>text</dc:type>
<dcterms:issued>2011-11-28T22:15:55-05:00</dcterms:issued>
</item>
而且PowerShell腳本:
$rssFeed = [xml](New-Object System.Net.WebClient).DownloadString('http://philadelphia.craigslist.org/sss/index.rss')
foreach ($item in $rssFeed.rdf.item) { $item.title }
將會產生這樣的:
#cdata-section
--------------
2006 BMW 650I,BLACK/BLACK/SPORT/AUTO
2006 BMW 650I,BLACK/BLACK/SPORT/AUTO
如何提取cdata部分?
我嘗試了幾個變體,例如$ item.title。「#cdata-section」和$ item.title.InnerText,它們什麼都不返回。我試過$ item.title | gm,我看到#cdata部分列爲屬性。我錯過了什麼?
謝謝。