How can I get plain text from test "Description" property from Simulink Test?

5 Ansichten (letzte 30 Tage)
I'm trying to read description text from my Simulink Test test file and all formatting is coming through as if it is an XML text.
A description in test manager can use bold, italic text, bulleting, etc. The output below is from an example with all different formatting used.
When I run these commands in the command window:
tf = sltest.testmanager.TestFile('example_tf')
tf.Description
the resulting description text looks like this:
'Example description text:<br /><br />Newline, <b>bold</b>, <i>italyc</i>, <u>underline </u>and <strike>strikethrough </strike>text<br /><ul><li>bulleting</li><li>is</li><li>also</li><li>affected </li></ul>'
Is it possible to read/convert this as plain text - to preserve only newlines and to discard other formatting when I load it into the base workspace?

Akzeptierte Antwort

MathWorks Support Team
MathWorks Support Team am 6 Okt. 2025 um 0:00
Bearbeitet: MathWorks Support Team am 6 Okt. 2025 um 17:28
As of MATLAB R2023a, the functionality to retrieve the plain text of the description from Simulink Test is not available. 
Instead, to remove the formatting, post process the formatted text using functions such as "erase", "regexprep", or "strrep" and reassign the output string to the object. Please refer to the following documentation pages for additional information:
An example of using "erase":
>> filterOut = ["<br />","<b>","</b>","<i>","</i>","<u>","</u>","<strike>","</strike>","<li>","</li>","<ul>","</ul>"]; % List of formats to remove
>> tf.Description = erase(tf.Description,filterOut)
tf =
TestFile with properties:
Name: 'example_tf'
FilePath: 'C:\Users\astepane\OneDrive - MathWorks\Documents\MATLAB\case sandbox\example_tf.mldatx'
Dirty: 1
Requirements: [0×1 struct]
Description: 'Example description text:Newline, bold, italyc, underline and strikethrough textbulletingisalsoaffected '
Enabled: 1
Tags: [0×0 string]
This allows you to define which formats to exclude. "Erase" will just remove the string, so to replace some of the formatting strings with spaces or new line characters, you can instead use "strrep" or "regexprep".

Weitere Antworten (0)

Produkte


Version

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by