Getting a Value from XML File
6 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!