Given the following XML file:
<packages>
<package name="Library">
<distributionPoints>
<distributionPoint path="http://SERVER001/SMS_DP_SMSPKGD$/CEN0003B/" />
<distributionPoint path="http://SERVER002/SMS_DP_SMSPKGD$/CEN0003B/" />
</distributionPoints>
<package name="SystemFiles">
<distributionPoints>
<distributionPoint path="http://SERVER001/SMS_DP_SMSPKGD$/CEN00262/" />
<distributionPoint path="http://SERVER002/SMS_DP_SMSPKGD$/CEN00262/" />
</distributionPoints>
</package>
</packages>
I am calling the function below to retrieve the information from “SystemFiles” node:
“http://SERVER001/SMS_DP_SMSPKGD$/CEN00262/”
“http://SERVER002/SMS_DP_SMSPKGD$/CEN00262/”
I am able to retrieve the node “SystemFiles” but am having an issue trying to retrieve info from inside it. Here is my function:
Function GetDistributionPath(packageName)
Dim foundPackageName
foundPackageName = false
Set objXml = CreateObject("Microsoft.XMLDOM")
If objXml.Load("Package.xml") Then
WScript.Echo "loaded successfully."
Else
WScript.Echo "I was not able to load XML doc Package.xml!"
WScript.Quit(1)
End If
Set packageNodes = objXml.documentElement.SelectNodes("//package")
For Each packageNode in packageNodes
If Not IsNull(packageNode.getAttribute("name")) Then
name = packageNode.getAttribute("name")
End If
If name = packageName Then
foundPackageName = true
'Get the DistributionPoint Paths
'THIS CODE BELOW IS NOT WORKING <=====
'Set distributionPointNodes = packageNode.SelectNodes("//distributionPoint")
'For Each distributionPointNode in distributionPointNodes
' distributionPointName = distributionPointNode.getAttribute("path")
' WScript.Echo "path: " & distributionPointName
'Next
Exit For
End If
Next
Set objXml = Nothing
If Not foundPackageName Then
WScript.Echo "I could not find package name " & packageName & " in Package.xml!"
WScript.Quit(1)
End If
End Function
'Other approache did not work as well
'Set objNode = objXml.selectSingleNode("packages/package[@name='SystemFiles']")
'WScript.Echo "Path: " & objNode.getAttribute("path")
Your published .XML is not well-formed (missing
</package>). You don’t say in what way the standard strategy:output:
does not work for you. So you have to check for yourself, where your work-around leaves the path of virtue.