2
我有以下XML嵌套XML Powershell的
以下PowerShell是讀取XML
write-host "`nParsing file SharepointSetUpData.xml`n"
[System.Xml.XmlDocument] $xd = new-object System.Xml.XmlDocument
$file = resolve-path("SharepointSetUpData.xml")
$xd.load($file)
#$nodelist = $xd.selectnodes("/testCases/testCase") # XPath is case sensitive
$nodelist = $xd.selectnodes("/WebApplications/WebApplication") # XPath is case sensitive
foreach ($testCaseNode in $nodelist) {
$WebAppid = $testCaseNode.getAttribute("id")
$inputsNode = $testCaseNode.selectSingleNode("SiteCollections")
$SiteCollection = $inputsNode.selectSingleNode("SiteCollection").get_InnerXml()
$siteslist = $SiteCollection.selectnodes("Site")
$optional = $inputsNode.selectSingleNode("SiteCollection").getAttribute("url")
$arg2 = $inputsNode.selectSingleNode("arg2").get_InnerXml()
$expected = $testCaseNode.selectSingleNode("expected").get_innerXml()
#$expected = $testCaseNode.expected
write-host "WebApp ID = $WebAppid SiteCollection = $SiteCollection Optional = $optional Arg2 = $arg2 Expected value = $expected"
}
的問題是線
$ siteslist = $ SiteCollection.selectnodes(簡稱 「網站」)
該網站列出無法找到。我如何找到這些。
謝謝羅伯特,工作的一種享受。我已經標記你的答案是正確的。 – vinnie