The path would be C:\Program Files\Backup\ConnectionInfo.xml. I am currently using this
if exists file “C:\Program Files\Backup\ConnectionInfo.xml” then line containing “Host” of file “C:\Program Files\Backup\ConnectionInfo.xml” as string else “N/A”, but I wind up getting this
I personally hate XML parsing and sometimes will be tempted to use the “lines of file” inspectors as you did… but in this straightforward XML, the XML inspectors are pretty simple to use… Use this:
q: node values of child nodes of selects “/MappableItem/PrimaryServer/Host” of xml document of file “C:\Program Files\Backup\ConnectionInfo.xml” as trimmed string
A: PAUCDP01.local.com
Thanks Ben, could you please let me know what the if exists would be? I got the dreaded, cannot parse line
If exists (node values of child nodes of selects “/MappableItem/PrimaryServer/Host” of xml document of file “C:\Program Files\Backup\ConnectionInfo.xml”) as trimmed string else “NA”
Update: Figured it out myself
If exsits file “C:\Program Files\Backup\ConnectionInfo.xml” then (node values of child nodes of selects “/MappableItem/PrimaryServer/Host” of xml document of file “C:\Program Files\Backup\ConnectionInfo.xml”) as trimmed string else “NA”
Thanks for steering me in the right direction Ben!
Is there a way to obtain the information of node values of child nodes on a xml file, the problem is that the child nodes have the same name, this is not a normal xml format.
-
-
ABCD
hostname
1111
-
EFGH
hostname
2222
node value of child nodes of xpaths “/xml/Item/name” of xml document of file “C:\xml.xml”
Error: Singular expression refers to non-unique object.
q: (node values of child nodes of xpaths “name” of it, node values of child nodes of xpaths “host” of it) of xpaths “/xml/Item” of xml document of file "C:\temp\test.txt"
A: ABCD, hostname
A: EFGH, hostname
what if the file is appended and so has duplicate copies of the information specified, is there syntax like “use last line of” that you can append to the above code just to read the latest value ?
whe I read in the value as above, say the port, what I get returned is 16384,16384 or occurring more depending on how many times the executable si run to create the XMl file.
in my case the clients run this everytime it is rebooted so the file could be appended any amount of times.
I can only think of one way off the top of my head, but it isn’t elegant:
node value of child nodes of selects
"/MappableItem/PrimaryServer/Port" of xml document of ((
"<MappableItem>" & following text of last
"<MappableItem>" of preceding text of last
"</MappableItem>" of concatenation of lines of file
"test.xml") &
"</MappableItem>")
Here’s how this works:
Concatenate all lines of the file in to a string
Drill down to the text between the last instance of and the last instance of
Re-append and to the beginning and end of the text from step 2.
Declare the text as an xml document and perform a select against it.
Honestly, if you just need the last instance of an element, such as , you may actually be better off using BigFix’s string parsing inspectors instead of trying to perform XML selects. I don’t really see any advantage to using XML inspectors in your scenario.