Parsing XML

(imported topic written by SystemAdmin)

Im trying to gather Software/Hardware names and versions from an HP, if you run “C:\hp\hpsmh\data\cgi-bin\vcagent\Discovery\hpsum_swdiscovery.exe”

with no command line options it ouputs a file called SWDiscovery.xml that contains all of the Firmware versions of each component in the system.

below is a small subsection of the output, this is the information you can get from the HP System Management Homepage / Version Control Agent

so heres what im trying to get

<component_name_xlate lang=“en”>HP NC-Series Broadcom 1Gb Multifunction Driver for Windows Server 2003</component_name_xlate>

4.6.112.0

<component_name_xlate lang=“en”>HP ProLiant Smart Array SAS/SATA Event Notification Service for Windows Server 2003/2008</component_name_xlate>

6.10.0.32

or

HP NC-Series Broadcom 1Gb Multifunction Driver for Windows Server 2003 4.6.112.0

HP ProLiant Smart Array SAS/SATA Event Notification Service for Windows Server 2003/2008 6.10.0.32

etc…

q: (node values of child nodes of xpaths “version” of it) of xpaths “/SWDiscovery/proliant_version_db/packages/package/installation_instance” of xml document of file “c:\software.xml”

\is what I have so far and that returns just the Verson numbers

<?xml version="1.0" encoding="UTF-8"?>

<proliant_version_db schema_version=“1.0.0”>

<installation_instance>

<package_file>cp009681.exe</package_file>

<definition_file>C:\CPQSYSTEM\cpxml\cp009681.xml</definition_file>

<component_name>

<component_name_xlate lang=“en”>HP NC-Series Broadcom 1Gb Multifunction Driver for Windows Server 2003</component_name_xlate>

<component_name_xlate lang=“ja”>HP NC???Broadcom 1Gb??? ??? for Windows Server 2003</component_name_xlate>

</component_name>

<component_description>

<component_description_xlate lang=“en”><![CDATA[

This Component Package contains the drivers for the HP NC-Series Broadcom 1Gb Multifunction Server Adapters for Windows Server 2003. This package contains VBD driver version 4.6.16.0, NDIS 5.2 driver version 4.6.14.0, iSCSI offload driver version 4.6.15.0, diagnostic driver version 4.6.4.0, crash dump driver version 4.6.0.0 and KMDF F6 install driver version 3.4.0.0.

]]></component_description_xlate>

<component_description_xlate lang=“ja”><![CDATA[

This Component Package contains the drivers for the HP NC-Series Broadcom 1Gb Multifunction Server Adapters for Windows Server 2003. This package contains VBD driver version 4.6.16.0, NDIS 5.2 driver version 4.6.14.0, iSCSI offload driver version 4.6.15.0, diagnostic driver version 4.6.4.0, crash dump driver version 4.6.0.0 and KMDF F6 install driver version 3.4.0.0.

]]></component_description_xlate>

</component_description>

<version_check_method/>

<kernel_installed_on/>

4.6.112.0

<install_state>installed</install_state>

<run_state>active</run_state>

<install_date year=“2008” month=“7” day=“8” hour=“4” minute=“52” second=“14”/>

</installation_instance>

<installation_instance>

<package_file>cp008921.exe</package_file>

<definition_file>C:\CPQSYSTEM\cpxml\cp008921.xml</definition_file>

<component_name>

<component_name_xlate lang=“en”>HP ProLiant Smart Array SAS/SATA Event Notification Service for Windows Server 2003/2008</component_name_xlate>

<component_name_xlate lang=“ja”>HP ProLiant Smart???SAS/SATA??? for Windows Server 2003/2008</component_name_xlate>

</component_name>

<component_description>

<component_description_xlate lang=“en”><![CDATA[

The HP Smart Array SAS/SATA Event Notification Service provides event notification to the Windows Server 2003 system event log and the HP ProLiant Integrated Management Log for systems using the HP Smart Array SAS/SATA controller driver.

]]></component_description_xlate>

<component_description_xlate lang=“ja”><![CDATA[

HP Smart???SAS/SATA???HP Smart???SAS/SATA??? ???Windows Server 2003??? ??? ???HP ProLiant??? ??? ???

]]></component_description_xlate>

</component_description>

<version_check_method/>

<kernel_installed_on/>

6.10.0.32

<install_state>installed</install_state>

<run_state>active</run_state>

<install_date year=“2008” month=“4” day=“30” hour=“20” minute=“22” second=“28”/>

</installation_instance>

</proliant_version_db>

(imported comment written by Lee Wei)

XML processing can be a lot of fun. Here are some examples for you.

q: (child node of child nodes whose (node value of attribute of it = “en”) of child nodes 2 of it as text & ", version - " & child node 6 of it as text) of child nodes of selects “/SWDiscovery/proliant_version_db/packages/package” of xml document of file “c:\temp\hp.xml”

A: HP NC-Series Broadcom 1Gb Multifunction Driver for Windows Server 2003, version - 4.6.112.0

A: HP ProLiant Smart Array SAS/SATA Event Notification Service for Windows Server 2003/2008, version - 6.10.0.32

q: (child nodes of child nodes whose (node value of attribute of it = “en”) of child nodes 2 of child nodes of selects “/SWDiscovery/proliant_version_db/packages/package” of xml document of file “c:\temp\hp.xml”) as text

A: HP NC-Series Broadcom 1Gb Multifunction Driver for Windows Server 2003

A: HP ProLiant Smart Array SAS/SATA Event Notification Service for Windows Server 2003/2008

q: node values of attributes of child nodes of child nodes 2 of child nodes of selects “/SWDiscovery/proliant_version_db/packages/package” of xml document of file “c:\temp\hp.xml”

A: en

A: ja

A: en

A: ja

q: (child nodes 6 of it as text) of child nodes of selects “/SWDiscovery/proliant_version_db/packages/package” of xml document of file “c:\temp\hp.xml”

A: 4.6.112.0

A: 6.10.0.32

q: (child nodes of child nodes whose (node value of attribute of it = “en”) of child nodes 2 of it as text, child nodes 6 of it as text) of child nodes of selects “/SWDiscovery/proliant_version_db/packages/package” of xml document of file “c:\temp\hp.xml”

A: HP NC-Series Broadcom 1Gb Multifunction Driver for Windows Server 2003, 4.6.112.0

A: HP ProLiant Smart Array SAS/SATA Event Notification Service for Windows Server 2003/2008, 6.10.0.32

Lee Wei

(imported comment written by SystemAdmin)

Thank you Lee, it seems that every XML I work with is more difficult the the last…

Thank you

q: ((child nodes of child nodes whose (node value of attribute of it = “en”) of child nodes 2 of it as text, child nodes 6 of it as text) of child nodes of selects “/SWDiscovery/proliant_version_db/packages/package” of xml document of file “c:\software.xml”)

A: HP NC-Series Broadcom 1Gb Multifunction Driver for Windows Server 2003, 4.6.112.0

A: HP ProLiant Smart Array SAS/SATA Event Notification Service for Windows Server 2003/2008, 6.10.0.32

A: HP ProLiant Array Configuration Utility for Windows, 8.10.1.0

A: HP ProLiant Integrated Lights-Out Management Interface Driver for Windows Server 2003/2008, 1.13.0.0

A: HP ProLiant Integrated Management Log Viewer for Windows, 5.21.0.0

A: HP ProLiant Remote Monitor Service for Windows Server 2003/2008, 5.20.0.0

A: HP Network Configuration Utility for Windows Server 2003, 9.60.0.0

A: HP Insight Management Agents for Windows Server 2003/2008, 8.10.0.0

A: HP Insight Management Agents for Windows Server 2003/2008, 8.10.0.0

A: HP Insight Management Agents for Windows Server 2003/2008, 8.10.0.0

A: HP Insight Management Agents for Windows Server 2003/2008, 8.10.0.0

A: HP Insight Management Agents for Windows Server 2003/2008, 8.10.0.0

A: Headless Server Registry Update for Windows, 1.0.0.0

How can I get “Unique values” if I use below I get an error

q: unique values of ((child nodes of child nodes whose (node value of attribute of it = “en”) of child nodes 2 of it as text, child nodes 6 of it as text) of child nodes of selects “/SWDiscovery/proliant_version_db/packages/package” of xml document of file “c:\software.xml”)

E: The operator “unique values” is not defined.

(imported comment written by SystemAdmin)

Got it ?

Q: unique values of ((child nodes of child nodes whose (node value of attribute of it = “en”) of child nodes 2 of it as text, child nodes 6 of it as text) of child nodes of selects “/SWDiscovery/proliant_version_db/packages/package” of xml document of file (pathname of parent folder of regapp “BESClient.exe”&"\SWDiscovery.xml")as string) as string

no need to reply… thanks again