How to get the attribute out of an XML file

3 次查看(过去 30 天)
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>

采纳的回答

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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Structured Data and XML Documents 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by