Create Custom property from .xml file

Hello Everyone! I’m trying to create custom properties based off of an .xml file that is going to be produced on a lot of my machines. I’m trying pin-point certain attributes buy using regex in the relevance. I’m having a heck of time getting anything back. Below is a section of my .xml file that I’m trying to bring back custom properties for (question continued after section example).

Why use regex to parse xml when there are xml inspectors?

Post your xml file (or a sanitised version of it) as xml.

Strip stuff out of the xml if it is huge or contains too much sensitive information by all means, but it does need to be xml.

Hello trn,

Thanks for the response. I need a running relevance to parse the xml on all the machines, and that is why I thought regex would be best. Is there a relevance the uses the xml inspectors? If there is I would really appreciate it if you could show me some examples of how this works. I have posted the xml below. I’ve never worked with xml files before. This is all new to me. Thanks.

OK, but that file would be easier to read if you used the forum facility to paste pre-formatted text (looks like </> in the input panel header).

You need to look at the reference material at developer.bigfix.com, specifically at https://developer.bigfix.com/relevance/reference/ and scroll to the bottom for the XML inspectors.

First thing is to read the file as XML, https://developer.bigfix.com/relevance/reference/xml-dom-document.html#xml-document-of-file-xml-dom-document
then use xpath to parse that https://developer.bigfix.com/relevance/reference/xml-dom-node.html#xpath-string-string-of-xml-dom-node-xml-dom-node.

All of the information appears to be jumbled into a single node of that file though, so you will need to do some text parsing to get the bit you need.

Apologies, I only have access to a phone atm and am on a long weekend, so I can’t develop/test anything. There are some real wizards on here though, so hopefully one of them will wander by and pitch in.

There is a good youTube video by one of the wizards at https://youtu.be/y__DnQLxpFk

I’ve spent some time this morning trying to make sense of the file contents you posted.

The best I can do is

[redacted at Bighize65’s request]

I’m no expert on xml, but this doesn’t look like valid xml to me - it is a mashup of an xml document and an xml schema.

If this is the file you have to work with then parsing it as text might be your best option.

q: (line ((maximum of line numbers of lines whose (it starts with "<diffgr:diffgram" ) of it) + 20 ) of file "c:\trn\sample2.xml") of file "c:\temp\badlyFormed.xml"
A: 36000:3
T: 7.042 ms
I: singular file line

q: lines whose (it = (regex "^\s*[\d]{4,6}:[\d]\s*$")) of file "c:\temp\badlyFormed.xml"
A: 36000:3
T: 5.161 ms
I: plural file line

Your results may vary, because my file was hacked together from your post above

I edited your post to put the XML inside a code tags. Please use the code tags (symbol looks like </> above the editor window).

Thanks and happy BigFixing

Thanks for your input. I will move forward with your advice and see if it will work. I appreciate the input gentleman.