Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
For searching in XML documents with the help of XPath (XPath is a W3C standard; see [W3C01]) the class XmlDocument supports the methods SelectNodes() and SelectSingleNode(). In PSCX, there is the commandlet Select-Xml (see Table 12.1).
$doc.SelectNodes("//URL") | Displays all <URL> elements |
| or | |
select-Xml h:\demo\powershell\xml\
websites.xml -XPath "//URL" |
select innerxml
$doc.SelectNodes("//Website/@ID") | |
| or | |
select-Xml h:\demo\powershell\
xml\websites.xml -XPath
"//Website/@ID" | select innerxml
$doc.SelectSingleNode
("//Website[@ID=3]/URL") | Displays all ID attributes of all <Website> elements |
| or | |
select-Xml h:\demo\powershell\ xml\websites.xml -XPath "//Website[@ID=3]/URL" | select innerxml | Displays the <URL>-element of the <Website> elements with the attribute value 3 in the attribute ID |