How to unify the code for reading XML file with varied field length?
조회 수: 2 (최근 30일)
이전 댓글 표시
To read the attribute value in an xml file like below with single field (length=1)
<A Xvalue="3">
</A>
I use AXvalue = A.Attributes.Xvalue to the value 3.
To read multiple attribute values in an xml file like below with two same fields with different attribute values:
<A Xvalue="3">
</A>
<A Xvalue="4">
</A>
I need to first get the length of the fields (how many fields) using ALth = Length(A) and then use following code
for iA=1:ALth
AXvalue = A{1,iA}.Attributes.Xvalue
end
Above case would not work for the case with ALth=1. So it would not work for the first case.
I am looking for a way to unify the code to get the attributes of above two different cases, no matter the value of ALth > or = 1. Is there any way to do that?
Thanks...
댓글 수: 1
Jarrod Rivituso
2012년 10월 31일
Hi Bruce,
Are you using a file exchange tool, such as xml2struct? Forgive my ignorance, but how do you convert your XML data to the format where you can enter
A{1,iA}.Attributes.Xvalue
-Jarrod
답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!