HP Server Parse XML

(imported topic written by FITZPAW91)

Hi all,

I have an XML that I am trying to get specific information out of.

The information I am trying to get is the Product_ID and Written_Version of Device_ID “0:0:1”, “0:0:2”, “0:0:3”, “0:0:4”, and if they don’t exist, leave it blank.

Here is the xml

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

I14

10/25/2010

ProLiant BL480c G1

Default System BIOS

123456789

8385576

0

1

GenuineIntel

6

3333MHz

1

4

0

0e11b203

103c3305

1

4

2

0e11b204

103c3305

1

3

0

1002515e

103c31fb

8

0

0

103c3230

103c3235

1

4

4

103c3300

103c3305

ACPI\FixedButton

System

ACPI\GenuineIntel_-_x86_Family_6_Model_23

Processeur Intel

Processor

intelppm

ACPI\GenuineIntel_-_x86_Family_6_Model_23

Processeur Intel

Processor

intelppm

ACPI\IPI0001

System

ACPI\PNP0100

Horloge système

System

ACPI\PNP0103

System

<storage_info>

<device_id value=“0”/>

<product_id value=“3235103C”/>

<active_version value=""/>

<written_version value=""/>

<associated_item/>

<last_staged_results/>

<device_id value=“0-A”/>

<product_id value=“3235103C”/>

<active_version value=“7.08”/>

<written_version value=“7.08”/>

<associated_item>

<controller_id value=“0”/>

<firmware_id value=“3235103C”/>

</associated_item>

<latest_staged_results value=""/>

<device_id value=“0:1:1”/>

<product_id value=“HP DG0146BALVN”/>

<active_version value=“HPD4”/>

<written_version value=“HPD4”/>

<associated_item>

<controller_id value=“0”/>

<firmware_id value=“3235103C”/>

</associated_item>

<latest_staged_results value=""/>

<device_id value=“0:1:2”/>

<product_id value=“HP DG0146BALVN”/>

<active_version value=“HPD4”/>

<written_version value=“HPD4”/>

<associated_item>

<controller_id value=“0”/>

<firmware_id value=“3235103C”/>

</associated_item>

<latest_staged_results value=""/>

<device_id value=“0:1:3”/>

<product_id value=“HP DG0300BALVP”/>

<active_version value=“HPD4”/>

<written_version value=“HPD4”/>

<associated_item>

<controller_id value=“0”/>

<firmware_id value=“3235103C”/>

</associated_item>

<latest_staged_results value=""/>

<device_id value=“0:1:4”/>

<product_id value=“HP DG0300BALVP”/>

<active_version value=“HPD4”/>

<written_version value=“HPD4”/>

<associated_item>

<controller_id value=“0”/>

<firmware_id value=“3235103C”/>

</associated_item>

<latest_staged_results value=""/>

</storage_info>

Thanks in advance for the help

William

(imported comment written by FITZPAW91)

Got it, but I need to do it in two relevances. Can someone please help me put both of these in one relevance.

if exists (lines whose (it contains “0:1:1”) of file “C:\hp\hpsmh\data\cgi-bin\vcagent\Discovery\hwdiscovery.xml”) THEN ((it as trimmed string) of following text of first “<product_id value=” of (item 1 of it) of (item 1 of it, lines of item 0 of it) whose (line number of item 1 of it = item 0 of it) of (it, (maximum of (line number of it + 1) of lines whose (it contains “0:1:1”) of it)) of file “C:\hp\hpsmh\data\cgi-bin\vcagent\Discovery\hwdiscovery.xml”) ELSE " "

if exists (lines whose (it contains “0:1:1”) of file “C:\hp\hpsmh\data\cgi-bin\vcagent\Discovery\hwdiscovery.xml”) THEN ((it as trimmed string) of following text of first “<active_version value=” of (item 1 of it) of (item 1 of it, lines of item 0 of it) whose (line number of item 1 of it = item 0 of it) of (it, (maximum of (line number of it + 2) of lines whose (it contains “0:1:1”) of it)) of file “C:\hp\hpsmh\data\cgi-bin\vcagent\Discovery\hwdiscovery.xml”) ELSE " "

Thanks

William

(imported comment written by Lee Wei)

The relevance language has XML inspectors that we can use.

Here is an example:

(
(attribute “value” of child node 0 of it) as text,
node name of child node 1 of it & “=” & (attribute “value” of child node 1 of it) as text,
node name of child node 3 of it & “=” & (attribute “value” of child node 3 of it) as text
) whose (
item 0 of it = “0:1:1” or
item 0 of it = “0:1:2” or
item 0 of it = “0:1:3” or
item 0 of it = “0:1:4”
) of child nodes of selects "/HWDiscovery/storage_info/devices"
of xml document of file “C:\hp\hpsmh\data\cgi-bin\vcagent\Discovery\hwdiscovery.xml”

Lee Wei

(imported comment written by FITZPAW91)

Thanks Lee

Works excellent, but not very clean as it is still showing parts of XML

product_id value=

written_version=

How would you clean this?

Thanks

William

(imported comment written by Lee Wei)

Yes we can remove the labels this way:

(
(attribute “value” of child node 0 of it) as text,
(attribute “value” of child node 1 of it) as text,
(attribute “value” of child node 3 of it) as text
) whose (
item 0 of it = “0:1:1” or
item 0 of it = “0:1:2” or
item 0 of it = “0:1:3” or
item 0 of it = “0:1:4”
) of child nodes of selects "/HWDiscovery/storage_info/devices"
of xml document of file “C:\hp\hpsmh\data\cgi-bin\vcagent\Discovery\hwdiscovery.xml”

(imported comment written by FITZPAW91)

Thanks alot Lee, worked great

William