I need some help parsing thorugh an xml file and then take the results and
write to a formatted xml file. I made some effort. The xml sample is below.
The purpose of xml defines all the property classes we want to pull data
for. The code below actually grabs the property class. I don't know how to
read the second argument(true/false) What I would like to happen is read all
the classes but before continuing to get the values is validate wether or
not I should get values based on the true or false argument. The purpose is
to have all the properties availiable and decide what we actually want to
grab. After validating if we should pull class data, I then need to look at
each Property PName and determine if I should grab only certain pieces are
everything based on the true/false. As I cycle through each Class and get
data, I want to write that info to another xml file.(End of file with dummy
values.)
'Main
Sig()
Function Sig()
'************************************************************
' Name: Sig
' Purpose:
' Inputs: None
' Returns: None
'************************************************************
Const StoreXML_DROPOFF_DIR = "C:\"
Const StoreXML_FileName = "NewXML.xml"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set xml = CreateObject("Microsoft.XMLDOM")
XML.async = False
XML.load StoreXML_DROPOFF_DIR & StoreXML_FileName
Set classes = XML.selectNodes("//SIGInventoryData/Class")
'numNodes = nodeList.Length
'For i = 0 To nodeList.length -1
For Each pclass In classes
className=pclass.Attributes.getNamedItem("CName").value
Set myNode = pclass.selectSingleNode("Property")
FindNodeValue = myNode.Text
WScript.Echo (className)
WScript.Echo(FindNodeValue)
Next
End Function
************************
Template xml file on what data to capture - Newxml.xml
************************
<SIGInventoryData>
<Class CName="LCD" CInventory="True">
<Property PName="brightness" PInventory="True"/>
<Property PName="backlight" PInventory="false"/>
</Class>
<Class CName="Audio" CInventory="True">
<Property PName="volumelevel" PInventory="True"/>
</Class>
</SIGInventoryData>
**********************************************
The format of the xml file with data pulled from template xml.
**********************************************
<Class CName="LCD">
<Property PName="brighness" Value="32"/>
</Class>
<Class CName="Audio">
<Property PName="volumelevel" Value="9"/>
</Class>