XML Inspector Issue

I found a Dell hardware inventory tool that outputs an XML containing all detected components, which allows me to build an analysis containing software and firmware versions, and create fixlets to upgrade these components.

Below is code that WORKS to return the CPLD firmware version:

from XML:

</Device>
     <Device componentID="27763" display="System CPLD">
  <Application componentType="FRMW" version="1.0.10" display="System CPLD"/>
</Device>

My full code:
if (exists file (data folder of client as string & "\MyCompany\DE_Avigilon\Avigilon.xml")) then ( if ("Avigilon" as trimmed string equals ( (it as string as trimmed string) of value "vendor" of structures "bios_information" of smbios )) then ( if (exists ((node values of attributes "version" of it) of xpaths "/SVMInventory/Device/Application[@componentType='FRMW'][@display='System CPLD']" of xml documents of files (data folder of client as string & "\MyCompany\DE_Avigilon\Avigilon.xml"))) then ( (node values of attributes "version" of it) of xpaths "/SVMInventory/Device/Application[@componentType='FRMW'][@display='System CPLD']" of xml documents of files (data folder of client as string & "\MyCompany\DE_Avigilon\Avigilon.xml") ) else nothing ) else nothing ) else nothing

The meat [@display=‘System CPLD’]:
(node values of attributes "version" of it) of xpaths "/SVMInventory/Device/Application[@componentType='FRMW'][@display='System CPLD']" of xml documents of files (data folder of client as string & "\MyCompany\DE_Avigilon\Avigilon.xml")

The problem is that other components contain additional information in the DISPLAY field that I do not need and cannot figure out how to properly query:

From XML:

<Device componentID="18981" display="Dell OS Driver Pack, 19.10.12, A00">
  <Application componentType="APAC" version="19.10.12" display="Dell OS Driver Pack, 19.10.12, A00"/>
</Device>

I need to find the display value that starts with “Dell OS Driver Pack” in @display=“Dell OS Driver Pack, 19.10.12, A00”. This version differs for each version of the OS Driver Pack.

it would be nice to be able to use something like:
(node values of attributes "version" of it) of xpaths "/SVMInventory/Device/Application[@componentType='FRMW'][@display starts with 'Dell OS Driver Pack']"
OR
(node values of attributes "version" of it) of xpaths "/SVMInventory/Device/Application[@componentType='FRMW'][@display='{(it as string starts with "Dell OS Driver Pack")}']"

any assistance is appreciated.

I think you’re getting your samples and your queries mixed up…your last example makes it look like you are searching for componentType ‘FRMW’ but in your sample data that won’t match, those components are componentType ‘APAC’

Basically you can do this search in a couple of different ways. I’m starting with a coerced sample XML based on your snippet

<SVMInventory>
<Device componentID="18981" display="Dell OS Driver Pack, 19.10.12, A00">
  <Application componentType="FRMW" version="19.10.12" display="Dell OS Driver Pack, 19.10.12, A00"/>
</Device>

<Device componentID="18982" display="Dell OS Driver Pack, 19.10.13, A00">
  <Application componentType="APAC" version="19.10.13" display="Dell OS Driver Pack, 19.10.13, A00"/>
</Device>

<Device componentID="18983" display="Something Else, 10.10.13, A00">
  <Application componentType="APAC" version="10.10.13" display="Something Else, 10.10.13, A00"/>
</Device>
</SVMInventory>

Within an XPath expression we could use the starts-with() function…here to match only where componentType=FRMW AND display starts with ‘Dell OS Driver Pack’ -

q: (node values of attributes "version" of it) of xpaths "/SVMInventory/Device/Application[@componentType='FRMW'][starts-with(@display,'Dell OS Driver Pack')]" of xml documents of files "c:\temp\test.xml"
A: 19.10.12
T: 0.736 ms
I: plural string

We could also skip the ‘componentType’ check to illustrate that we match all the components starting with ‘Dell OS Driver Pack’:

q: (node values of attributes "version" of it) of xpaths "/SVMInventory/Device/Application[starts-with(@display,'Dell OS Driver Pack')]" of xml documents of files "c:\temp\test.xml"
A: 19.10.12
A: 19.10.13

The XPath expressions and comparisons can be limited though, so another approach would be to retrieve the ‘version’, 'display, and ‘componentType’ attributes as separate tuple items and do the filtering/comparison in Relevance instead of in XPath expressions. Here I also use the pipe operator ' | ' to substitute in a blank value if one of the attributes does not exist:

q: (node value of attribute "version" of it | "",  node value of attribute "componentType" of it | "", node value of attribute "display" of it | "") of xpaths "/SVMInventory/Device/Application" of xml documents of files "c:\temp\test.xml"
A: 19.10.12, FRMW, ( Dell OS Driver Pack, 19.10.12, A00 )
A: 19.10.13, APAC, ( Dell OS Driver Pack, 19.10.13, A00 )
A: 10.10.13, APAC, ( Something Else, 10.10.13, A00 )

With those retrieved, we could do the filtering in Relevance with a whose() clause:

q: (node value of attribute "version" of it | "",  node value of attribute "componentType" of it | "", node value of attribute "display" of it | "") whose (item 1 of it = "APAC" and item 2 of it starts with "Dell") of xpaths "/SVMInventory/Device/Application" of xml documents of files "c:\temp\test.xml"
A: 19.10.13, APAC, ( Dell OS Driver Pack, 19.10.13, A00 )

Hope this helps!

wow! thanks for the fast and comprehensive reply! [starts-with(@display,‘Dell OS Driver Pack’)] did the trick. Much appreciated.