How to unify the code for reading XML file with varied field length?
1 次查看(过去 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!