%% Process a Node List Using Zero-Based Indexing
% This example displays the text content of the day elements in the file days.xml by using the item method of the matlab.io.xml.dom.NodeList object that contains the elements.
% Create a document from the days.xml file.

import matlab.io.xml.dom.*
doc = parseFile(Parser,"days.xml");

% Call the getElementsByTagName method to return the element nodes named day as a matlab.io.xml.dom.NodeList object.

list = getElementsByTagName(doc,"day");

% Display the text content of each element node in the list. Start with index 0 because the item method uses zero-based indexing.

n = getLength(list)-1;
for i = 0:n
   dayElem = item(list,i);
   disp(getTextContent(dayElem));
end

%
% Copyright 2020 The MathWorks, Inc.