Getting a Value from XML File

6 次查看(过去 30 天)
Eddie Martin
Eddie Martin 2020-8-11
So I've been trying to figure out XML file formats as I am very new to them. I feel I am getting close but not quite there. I have uploaded a version of the XML as a .txt file with only the pertinent info in. Below is my code:
Params = xmlread('Test1text.xml').getElementsByTagName('ParameterValue');
for k = 0:Params.getLength-1
thisParam = Params.item(k);
thisAttr = thisParam.getAttribute('parameter');
if thisAttr == 'pa9'
ParamChildren = thisParam.getChildNodes;
thisData = ParamChildren.item(0);
Ex = thisData
disp('Ex');
disp(Ex);
end
end
Unfortunatley this outputs:
" Ex
[#text:
] "
From the attatched xml, I would like it to output something like:
Ex
181
Therefore, I will have assigned the value of the Data node ( that is the child of the ParamererValue node with attribute parameter = "pa9" ) to var Ex
Really appreciate any and all help/advice.

回答(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