Getting a Value from XML File

6 views (last 30 days)
Eddie Martin
Eddie Martin on 11 Aug 2020
Edited: Eddie Martin on 11 Aug 2020
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.

Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!