Read XML Node with Children into DictionaryObject
Define the XML required eg
<Servers>
<Server Name="Server1", ip="192.168.1.1" />
<Server Name="Server2", ip="192.168.1.2" />
</Servers>
and call the function as
Value=ReadXMLNode(<"//Servers/Server","Name","ip",objDictionary)
If the return value is "ERROR" then the node could not be read, otherwise objDictionary will contain a set of key value pairs corresponding to for the example
- Object contains
- Key Value
- Server1 192.168.1.1
- Server2 192.168.1.2
SCRIPT CODE
'*********************************************************************************
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
' EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
' WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
'
' IF YOU WANT THIS FUNCTIONALITY TO BE CONDITIONALLY SUPPORTED,
' PLEASE CONTACT ONE IDENTITY PROFESSIONAL SERVICES.
'*********************************************************************************
Public Function ReadXMLNodesToDictionary(ByVal strNodeName,ByVal key, ByVal Value, ByRef ObjDictionary)
Set objXMLDoc = CreateObject("Microsoft.XMLDOM")
objXMLDoc.async = False
If fileexists("ars control.xml") Then
objXMLDoc.load("ars control.xml")
Set Nodes = objXMLDoc.selectNodes(strnodename)
For Each node In Nodes
eventlog.reportevent 5, "Scanning Node : " & node.Attributes.getNamedItem(key).text
objDictionary.add node.Attributes.getNamedItem(key).text, node.Attributes.getNamedItem(value).text
Next
Else
ReadXMLNodesToDictionary="ERROR"
End If
End Function
'***** END OF CODE ***************************************************************