XML Parsing Help

Hopefully this will be a quick one for someone. We have to be overlooking something silly here…

XML File: Attached

We are trying to simply pull the Home NAME as a result from the query below, but it returns as blank:

(it as text) of xpaths “INVENTORY/VERSION_INFO/HOME_LIST/HOME/Name” of xml document of file “C:\Program Files (x86)\Oracle\Inventory\ContentsXML\inventory.xml”

We do have success pulling the version from this same XML document via the command below:

If exists file “C:\Program Files (x86)\Oracle\Inventory\ContentsXML\inventory.xml” then ((node values of child nodes of selects “INVENTORY/VERSION_INFO/SAVED_WITH” of xml document of file “C:\Program Files (x86)\Oracle\Inventory\ContentsXML\inventory.xml”) as trimmed string) else “Not Applicable”


I am sure we are overlooking something silly so if someone could assist it would be greatly appreciated!!


I can’t see your attachment on my phone, but I’d point out your mixed use of ‘xpaths’ vs ‘selects’ between the two queries.

You’ll likely need something like node values of child nodes of xpaths "..." rather than (it as text) of xpaths "...".

Xpath returns a node, you need to either get its node value or its child node’s node value.

I’d start from the top, retrieving
(node name of it | "no name", node value of it | "no value") of (it, child nodes of it) of xpaths "INVENTORY" of xml document of file “C:\Program Files (x86)\Oracle\Inventory\ContentsXML\inventory.xml”

That will help illustrate where you are in the tree, and as you get a result you can further build the xpath value to drill down to the node you want.

Have you tried to use the “Dictionary” inspector?

I use it to evaluate the contents of plist files on Macintosh systems.

For example,

if (exists Folder "/Library/BESAgent/BESAgent.app") THEN ((string "CFBundleVersion" of dictionary of file "/Library/BESAgent/BESAgent.app/Contents/Info.plist") as string) ELSE (NOTHING)

Thanks for the quick replies! We identified the issue with help from another member on the forms using:

node value of xpath “/INVENTORY/HOME_LIST/HOME/@NAME” of xml document of file “C:\Program Files (x86)\Oracle\Inventory\ContentsXML\inventory.xml”

Couple of questions though.

  1. Is there a method to make the above call for two different directories rather than just the one? The inventory.xml file could be in “C:\Program Files (x86)\Oracle\Inventory\ContentsXML\inventory.xml” or “C:\Program Files\Oracle\Inventory\ContentsXML\inventory.xml” How can we make one call to check both locations?

  2. How can we list multiple results if there are any for the @Name attribute in essence to question #1?

For the first query, there are a couple of different methods. I’d recommend
xml documents of files “Oracle\Inventory\ContentsXML\inventory.xml” of (program files x32 folders; program files x64 folders)

For the second, I don’t have a debugger handy but I think you could use xpath searching via

node values of xpaths “//@NAME” of xml documents of ...

1 Like