필터 지우기
필터 지우기

reading data in xml format

조회 수: 7 (최근 30일)
Tom Wright
Tom Wright 2015년 9월 2일
댓글: Cedric 2015년 9월 4일
<xml>
<node1>
<val>5</val>
<val>7</val>
</node1>
</xml>
xml_vals = node.item(0).getElementsByTagName('val');
values = zeros(1,xml_vals.getLength);
for iVal = 1:xml_vals.getLength-1
values(iVal+1) = str2num(xml_vals.item(iVal).getFirstChild.getData);
end
Is there a simple way to use an XMLDom to get all the values directly into a vector? Currently I am looping through them but this is very slow.
  댓글 수: 1
Cedric
Cedric 2015년 9월 4일
How large/complex is your XML file?

댓글을 달려면 로그인하십시오.

답변 (1개)

Shruti Sapre
Shruti Sapre 2015년 9월 4일
Hi Tom,
I understand that you want to read all the values of an xml into a vector. I tried to look this up and couldn’t find an existing function or a direct way to do this.
There is a function on MATLAB Central that reads xml into a MATLAB structure, maybe this could help you perform the parsing faster:
Here is another link that may help you with easy access to values in an xml:
Alternatively, you could try the “parseXML” function in the below documentation link to check if this makes the process a bit faster:
Hope this helps!
-Shruti

카테고리

Help CenterFile Exchange에서 String Parsing에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by