Getting a Value from XML File

조회 수: 16 (최근 30일)
Eddie Martin
Eddie Martin 2020년 8월 11일
편집: 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