Omitting HTML tags from message of bes fixlet

I’m writing a relevance query to return details about relevant fixlets.One of the bes fixlet properties (message of ) appears to return the information I need, however it’s intermingled with HTML markup. Is there a way to obtain the message information as plain text (i.e. without the markup)?

Thanks.

What is it that you are looking for? There is some info in Metadata that might be easier to get if it is what you are trying to find.

Can you provide an example of the relevance you used and the result? (you will need to put it in a pre-formatted block)

In the query below the clause message of it returns a block of HTML with lots of useful information describing the fixlet. I was looking for a way to fetch just the information without the HTML markup. Looking at the documentation for the bes fixlet session object, I don’t see any obvious way to do this. I’ve tried message of it as string, but that has no apparent effect.

(hostname of it,
	ip addresses of it as string, 
	operating systems of it,
	(id of it, 
		name of site of it,
		name of it, 
		source of it, 
		categories of it, 
		message of it,
		(if exists cve id lists of it then concatenation ";" of cve id lists of it else "none"),
		source severity of it)
	of relevant fixlets
	whose (source severity of it != ""
	and source severity of it != "<Unspecified>"
	and source severity of it != "Unspecified"
	and source severity of it != "N/A"
	and task flag of it = false) of it)
of bes computers

The output of this query is lengthy. Here’s just the first “row”. As you can see, the descriptive detail is wrapped inside an HTML table with other markup. I was just wondering if there is a way to get the same information without the HTML.

TI-IBMSC-MANAGER.TI.local, 192.168.25.55, Win2008R2 6.1.7601, ( 177, BES Support, Restart Needed, BigFix, Computer Support, ( <TABLE><TBODY><TR><TD> <P>The listed computers have pending operations that are waiting for a restart. This Fixlet message will become relevant when the computer is in a 'pending restart' state, regardless if the 'pending restart' state was triggered by a BES action. </P> <P><STRONG>Note:</STRONG> For pre-6.0 versions of BES, the BES Clients will not restart unless you set the appropriate post-action restart options through the "Take Action Dialog". For BES 6.0+, the standard restart behavior will be set in the "Take Action Dialog", but you can customize other options to match the intended restart behavior.</P><P>To determine whether or not a computer is in the pending restart state due to a BES action, please see the following Fixlet messages:<ul><li><SPAN id="relTag2Script8"></SPAN><SCRIPT type="text/javascript">var isEvansOrLater = '<?relevance if (exists property "datastore inspectors") then (True) else (False)?>' == 'True'?true:false; try{if (isEvansOrLater) {document.getElementById("relTag2Script8").innerHTML=Relevance('if (exists (fixlet 390 of bes site whose (name of it equals "BES Support"))) then ( ((format "<?rxlat {0} ({1} relevant computers)?>" + link of it as string + applicable computer count of it as string ) as string) of (fixlet 390 of bes site whose (name of it equals "BES Support")) ) else ("<?rxlat Fixlet unavailable?>")');} else {document.getElementById("relTag2Script8").innerHTML=EvaluateRelevance('if (exists (fixlet 390 of bes site whose (name of it equals "BES Support"))) then (link of it as string & " (" & applicable computer count of it as string & " relevant computers)") of (fixlet 390 of bes site whose (name of it equals "BES Support")) else "Fixlet unavailable"');}}catch(e){}</SCRIPT><li><SPAN id="relTag2Script12"></SPAN><SCRIPT type="text/javascript">var isEvansOrLater = '<?relevance if (exists property "datastore inspectors") then (True) else (False)?>' == 'True'?true:false; try{if (isEvansOrLater) {document.getElementById("relTag2Script12").innerHTML=Relevance('if (exists (fixlet 391 of bes site whose (name of it equals "BES Support"))) then ( ((format "<?rxlat {0} ({1} relevant computers)?>" + link of it as string + applicable computer count of it as string ) as string) of (fixlet 391 of bes site whose (name of it equals "BES Support")) ) else ("<?rxlat Fixlet unavailable?>")');} else {document.getElementById("relTag2Script12").innerHTML=EvaluateRelevance('if (exists (fixlet 391 of bes site whose (name of it equals "BES Support"))) then (link of it as string & " (" & applicable computer count of it as string & " relevant computers)") of (fixlet 391 of bes site whose (name of it equals "BES Support")) else "Fixlet unavailable"');}}catch(e){}</SCRIPT></ul></P><P><B>Note:</B> When running the action below, you should pay careful attention to the action deployment options in order to avoid restarting the computer at inappropriate times.</P> <P><STRONG>Note:</STRONG> Click <A href="http://support.bigfix.com/cgi-bin/kbdirect.pl?id=159">here</A> for more information on how the 'pending restart' status is determined.</P></TD></TR></TBODY></TABLE> ), none, Moderate )

What is the information in the message do you want to get?

Using the example from my previous post, it would be nice to be able to fetch the following two paragraphs:

The listed computers have pending operations that are waiting for a restart. This Fixlet message will become relevant when the computer is in a 'pending restart' state, regardless if the 'pending restart' state was triggered by a BES action. 

Note:; For pre-6.0 versions of BES, the BES Clients will not restart unless you set the appropriate post-action restart options through the "Take Action Dialog". For BES 6.0+, the standard restart behavior will be set in the "Take Action Dialog", but you can customize other options to match the intended restart behavior.

Try something like this:

( concatenations "" of substrings separated by "</STRONG>" of concatenations "" of substrings separated by "<STRONG>" of concatenations "" of substrings separated by "<P>" of concatenations "NEWLINE_CHARACTER" of tuple string items (0;1) of concatenations ", " of substrings separated by "</P>" of following text of first "<P>" of it) of message of it

Where tuple string items (0;1) of controls the number of paragraphs returned, though it won’t work completely correctly due to there already being ", " characters in the paragraph.

Obviously I don’t remember the % encodes for the NEWLINE_CHARACTER.

Actually, I was hoping there was another property containing the “raw” data defined somewhere. I looked, but couldn’t find one. That said, I really don’t want to get in the business of stripping-off HTML tags using relevance. I’ll live with the HTML. Thanks for your help.

The HTML is the “raw” data.

I haven’t tested the above relevance, but it should be pretty easy to create relevance that will give you a particular set of paragraphs of HTML as raw text.

Why don’t you want to use relevance to strip off the HTML tags if it works?

The HTML is the “raw” data.

That’s essentially what I was trying to confirm.

Why don’t you want to use relevance to strip off the HTML tags if it works?

Admittedly I don’t know relevance very well-- never even heard of it until 3 weeks ago. But I do have a lot of experience processing structured XML/HTML documents. One thing I’ve learned (the hard way) is that to do so correctly you really need a tool such as a validating parser-- something that accounts for the recursive nature of such documents and makes no assumptions as to content. You can write the most elegant regular expression or other string-manipulating code that works just fine for 98% of the documents you feed it. And then one day somebody gives it a document that just blows that logic out of the water. I’d be very wary of any code that purports to handle HTML data by indexing through strings or substrings and/or attempts to locate literal values within that data.

I’ll live with the data as it is presented.

1 Like

I do agree that parsing HTML is complicated and problematic. Even so it is possible to write relevance that will work in most cases, and should fail gracefully.

This is a working example:

(concatenations "" of substrings separated by "</b>" of substrings separated by "</B>" of substrings separated by "<b>" of substrings separated by "<B>" of substrings separated by "<p>" of substrings separated by "<P>" of it) of (concatenations "," of substrings separated by "!COMMA!" of concatenations "%0d%0a" of tuple string items (0;1) of concatenations ", " of substrings separated by "</p>" of substrings separated by "</P>" of it) of (concatenations "!COMMA!" of substrings separated by "," of it) of (following text of first "<p>" of it | following text of first "<P>" of it) of (it as string) of message of bes fixlets whose(119570110=id of it)

The tuple string items (0;1) above tells the relevance to return the first 2 paragraphs of the HTML.

This would need to handle a few more cases to strip out more HTML tags, like STRONG and italics, but it is functional.