How to get the attribute out of an XML file

13 views (last 30 days)
I have an XML like the below. I am able to use xml2struct (in the file exchange) to read the file. My question is how do I read the contents of "label" (DISSOLVED OXYGEN, pH) out of such files?
<datatypes>
<datatype id="116" label="DISSOLVED OXYGEN"/>
<datatype id="257" label="pH"/>
</datatypes>

Accepted Answer

Leon
Leon on 25 Oct 2017
Figured it out myself.
xDOC = xml2struct('data/abc.xml');
A = xDOC.datatypes.datatype;
for i=1:length(A);
dataType = A{i}.Attributes.label;
end;

More Answers (0)

Tags

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!