이 XML 문서가 있습니다.
<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
<channel>
<title>ps read XML File</title>
<description>Some Text</description>
<item>
<title>Element One</title>
<description>Some Text to Element ONE</description>
<guid>http://dlbmodigital.microsoft.com/webcasts/wmv/23976_Dnl_L.wmv</guid>
</item>
<item>
<title>Element Two</title>
<description>Some Text to Element TWO</description>
<guid>http://dlbmodigital.microsoft.com/webcasts/wmv/23977_Dnl_L.wmv</guid>
</item>
<item>
<title>Element Three</title>
<description>Some Text to Element Three</description>
<guid>http://dlbmodigital.microsoft.com/webcasts/wmv/23978_Dnl_L.wmv</guid>
</item>
</channel>
</rss>
"guid"요소에서 값을 포착하고 싶습니다. 그러나 나는 방법을 모른다.
이 코드로
"[xml]$xmldata = Get-Content -path C:\tmp\ps\test-ps.xml
$xmldata.rss.channel.item"
세 개의 "항목"요소가 표시됩니다. 하지만 요소 "guid"에서 값 (Hyperlink)을 어떻게 잡을 수 있는지 전혀 모릅니다.
모든 guid-elements를 원한다면 다음과 같이 xpath를 사용할 수 있습니다.
$xmldata.SelectNodes('//guid') | Select-Object -ExpandProperty "#text"
http://dlbmodigital.microsoft.com/webcasts/wmv/23976_Dnl_L.wmv
http://dlbmodigital.microsoft.com/webcasts/wmv/23977_Dnl_L.wmv
http://dlbmodigital.microsoft.com/webcasts/wmv/23978_Dnl_L.wmv
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다