Getting a Value from XML File

6 visualizaciones (últimos 30 días)
Eddie Martin
Eddie Martin el 11 de Ag. de 2020
Editada: Eddie Martin el 11 de Ag. de 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.

Respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by