How to unify the code for reading XML file with varied field length?
Mostrar comentarios más antiguos
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 comentario
Jarrod Rivituso
el 31 de Oct. de 2012
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
Respuestas (0)
Categorías
Más información sobre Structured Data and XML Documents en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!