我很难在内部阅读带有Cdata的XML文件。
$ xmlsource 中的<list>
<topic>
<topicTitle>Test</topicTitle>
<topicDetail><![CDATA[<br>randomHTMLhere</br>]]></topicDetail>
</topic>
</list>
[xml]$xml = get-content $xmlsource
foreach ($topic in $xml.list) {
$topic.topicTitle
$topic.topicDetail
}
$ topic.topicDetail将为null,而$ topic.topicTitle将不为。有什么想法吗?
答案 0 :(得分:22)
$topic.topicDetail."#cdata-section"
或
$topic.topicDetail.InnerText