%% Create XML Import Options for XML File
% Create XML import options for an XML file, specify the variables to import, and then read the data.
% The XML file students.xml has four sibling nodes named Student, which each contain the same child nodes and attributes.

type students.xml

% Create an XMLImportOptions object from a file. Specify the value of VariableSelectors as //@FirstName to select the FirstName element node to import as a table variable.

opts = xmlImportOptions("VariableSelectors","//@FirstName")

% Use readtable along with the options object to import the specified variable.

T = readtable("students.xml",opts)

% Copyright 2020 The MathWorks, Inc.