%% Find Elements in HTML Tree
% Read HTML code from the URL https://www.mathworks.com/help/textanalytics using the webread function.

url = "https://www.mathworks.com/help/textanalytics";
code = webread(url);

% Parse the HTML code using htmlTree.

tree = htmlTree(code);

% Find all the hyperlinks in the HTML tree using findElement. The hyperlinks are nodes with element name "A".

selector = "A";
subtrees = findElement(tree,selector);

% View the first few subtrees.

subtrees(1:10)

% Extract the text from the subtrees using extractHTMLText. The result contains the link text from each link on the page.

str = extractHTMLText(subtrees);
str(1:10)

% Copyright 2018 The MathWorks, Inc.