Title
Body & tail
\";\nstr = extractHTMLText(code, \"ExtractionMethod\", \"all-text\")"},{"@type":"HowToStep","name":"Extract From htmlTree","url":"https://runmat.com/docs/reference/builtins/extracthtmltext#extract-from-htmltree","text":"tree = htmlTree(\" Body & tailTitle
No. Both modes currently use RunMat's paragraph/block extraction heuristic. Exact article scoring remains part of the broader Text Analytics compatibility work.
"}},{"@type":"Question","name":"Does `extractHTMLText` support arrays?","acceptedAnswer":{"@type":"Answer","text":"
Yes. Text arrays and cells produce string arrays with the same shape. Cells containing htmlTree objects are also supported.
"}},{"@type":"Question","name":"Does `extractHTMLText` execute on the GPU?","acceptedAnswer":{"@type":"Answer","text":"
No. HTML extraction is host text processing and has no runmat-accelerate provider path.
"}}]}]}
extractHTMLText — Extract visible text from HTML code or htmlTree objects.extractHTMLText extracts visible text from HTML code or from an htmlTree object. It supports the documented ExtractionMethod option values "tree", "article", and "all-text".
str = extractHTMLText(code)
str = extractHTMLText(___, 'ExtractionMethod', method)| Name | Type | Required | Default | Description |
|---|---|---|---|---|
code | Any | Yes | — | HTML code or htmlTree object. |
Name | StringScalar | Yes | ExtractionMethod | Extraction method option name. |
method | StringScalar | Yes | tree | Extraction method: tree, article, or all-text. |
| Name | Type | Description |
|---|---|---|
str | Any | Extracted text. |
| Identifier | When | Message |
|---|---|---|
RunMat:html:InvalidInput | Inputs are not a supported htmlTree or extractHTMLText form. | HTML Text Analytics helper received invalid input |
extractHTMLText worksextractHTMLText(code) accepts string scalars, character vectors, string arrays, multi-row character arrays, and cell arrays of character vectors.extractHTMLText(tree) accepts scalar RunMat htmlTree objects created by htmlTree.extractHTMLText(___, 'ExtractionMethod', method) accepts tree, article, or all-text.tree and article currently use the same paragraph/block extraction heuristic. RunMat does not yet implement MathWorks' exact article scoring algorithm.all-text extracts normalized body text outside skipped elements. Whitespace is normalized for MATLAB-friendly string output.extractHTMLText parses host-resident text and has no provider kernel.
code = "<html><body><h1>THE SONNETS</h1><p>by William Shakespeare</p></body></html>";
str = extractHTMLText(code)Expected output:
str = "THE SONNETS\n\nby William Shakespeare"code = "<body><style>.x{}</style><p>visible</p><script>hidden()</script><span>tail</span></body>";
str = extractHTMLText(code, "ExtractionMethod", "all-text")Expected output:
str = "visible tail"tree = htmlTree("<article><h2>Title</h2><p>Body & tail</p></article>");
str = extractHTMLText(tree)Expected output:
str = "Title\n\nBody & tail"extractHTMLText with coding agentsOpen a RunMat example with live inputs, then ask the agent to explain how extractHTMLText changes the result.
Run a small extractHTMLText example, explain the result, then change one input and compare the output.
tree and article exact MATLAB article extraction modes?⌄No. Both modes currently use RunMat's paragraph/block extraction heuristic. Exact article scoring remains part of the broader Text Analytics compatibility work.
extractHTMLText support arrays?⌄Yes. Text arrays and cells produce string arrays with the same shape. Cells containing htmlTree objects are also supported.
extractHTMLText execute on the GPU?⌄No. HTML extraction is host text processing and has no runmat-accelerate provider path.
addDependencyDetails · addEntityDetails · addLemmaDetails · addPartOfSpeechDetails · addSentenceDetails · addTypeDetails · bagOfNgrams · bagOfWords · cosineSimilarity · doc2sequence · encode · extractFileText · fastTextWordEmbedding · findElement · getAttribute · htmlTree · ind2word · isVocabularyWord · normalizeWords · readWordEmbedding · removeLongWords · removeShortWords · removeStopWords · removeWords · stopWords · tokenDetails · tokenizedDocument · trainWordEmbedding · vaderSentimentScores · vec2word · word2ind · word2vec · wordEncoding · writeWordEmbedding
append · deblank · erase · eraseBetween · erasePunctuation · eraseURLs · extractAfter · extractBefore · extractBetween · insertAfter · insertBefore · join · lower · pad · replace · replaceBetween · reverse · split · splitlines · strcat · strip · strjoin · strjust · strrep · strsplit · strtrim · upper
blanks · char · compose · convertCharsToStrings · convertContainedStringsToChars · convertStringsToChars · genvarname · int2str · isletter · isspace · isStringScalar · isstrprop · mat2str · native2unicode · newline · num2str · sprintf · sscanf · str2double · str2num · strcmp · strcmpi · string · string.empty · strings · strlength · strncmp · strncmpi · strtok · unicode2native
contains · endsWith · matches · startsWith · strfind
digitsPattern · lettersPattern · pattern · regexpPattern · textBoundary · wildcardPattern
Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how extractHTMLText is executed, line by line, in Rust.
RunMat is an open-source runtime that executes MATLAB-syntax code blazing on any GPU. It is licensed under the Apache 2.0 license.
Download RunMat for full performance, or use RunMat in your browser for zero setup.