%% Evaluate an XPath Expression in the Context of an XML File
% This example evaluates an XPath expression that finds the nodes with the name Instrument in the file music.xml.
% The file music.xml contains this XML markup:
% <MusicalEnsemble>
% 	<Ensemble>
% 		<Music>Jazz</Music>
%             <BandName>Kool Katz</BandName>
% 		<Instrumentation>
% 			<Instrument type="wind">Trumpet
%             </Instrument>
% 			<Instrument type="percussion">Piano
%                 <pianotype>concert grand</pianotype>
%             </Instrument>
% 			<Instrument type="percussion">Drums
%                 <drumkit>Bass drum</drumkit>
%                 <drumkit>Floor tom</drumkit>
%                 <drumkit>Snare drum</drumkit>
%                 <drumkit>Hi-hat</drumkit>
%                 <drumkit>Ride cymbal</drumkit>
%             </Instrument>
% 			<Instrument type="string">Bass
%                 <basstype>upright</basstype>
%             </Instrument>
% 		</Instrumentation>
% 	</Ensemble>
%     <Musicians>
%         <Name role="trumpeter">Miles</Name>
%         <Name role="vocalist">Roger</Name>
%         <Name role="pianist">Diana</Name>
%         <Name role="drummer">George</Name>
%         <Name role="bassist">John</Name>
%     </Musicians>
% </MusicalEnsemble>
% Define the XPath expression and specify the XML file.

import matlab.io.xml.xpath.*

xpExpr = "//Instrument";
xmlFilePath = "music.xml";

% Evaluate the XPath expression and return the nodes as a vector of node objects.

data = evaluate(Evaluator,xpExpr,xmlFilePath,EvalResultType.NodeSet)

%
% Copyright 2020 The MathWorks, Inc.