xml2struct does not return all children

4 visualizaciones (últimos 30 días)
luca pavarino
luca pavarino el 2 de Abr. de 2020
Respondida: Harshendra Shah el 9 de Abr. de 2020
Hello,
I am trying to read a .xml file into a Matlab structure using xml2struct (from https://it.mathworks.com/matlabcentral/fileexchange/28518-xml2struct). It runs without errors on my input xml file (listed below since I was not abel to attach it), but the output does not have all the children in my xml file. I see only Volume, but not all the others (Vertices, Map_data, Map_color, Map_status, Normals, Polygons, Surface_of_origin).
Could you please tell me how to fix xml2str ? Thank you,
Luca
My input xml file is the following (I could not attach it):
<?xml version="1.0" encoding="UTF-8"?>
<DIF>
<DIFHeader>
<Version>SJM_DIF_5.0</Version>
</DIFHeader>
<DIFBody>
<Volumes number="1">
<Volume name="Surface1" color="">
<!-- St. Jude Medical Dx Landmark Geo data export; file format revision 0 -->
<!-- Exported from study study_dwsG600217_2020_01_09_11_12_22 -->
<!-- 4x4 column-major matrix A that transforms "model coordinates" -->
<!-- xyz_vert to EnSite application display coordinates -->
<!-- xyz_displ (left-superior-anterior). Upper left 3x3 -->
<!-- submatrix is rotation; right column is translation from sysRef. -->
<!-- [ x_displ ] [ A0 A4 A8 A12 ] [ x_vert ] -->
<!-- [ y_displ ] = [ A1 A5 A9 A13 ] [ y_vert ] -->
<!-- [ z_displ ] [ A2 A6 A10 A14 ] [ z_vert ] -->
<!-- [ 1.0 ] [ A3 A7 A11 A15 ] [ 1.0 ] -->
<AP_MapViewMatrix> 1.000000 0.000000 0.000000 0.000000 0.000000 0.000000 -1.000000 0.000000 0.000000 1.000000 0.000000 0.000000 16.248789 -451.386292 0.000000 1.000000 </AP_MapViewMatrix>
<Vertices number="10">
-19.0210 -33.6089 447.5374
-18.0380 -33.3185 447.4422
-19.2899 -32.4262 447.7701
-20.8341 -33.6710 447.8590
-20.1785 -34.4075 447.8537
-18.9832 -34.7589 447.9247
-17.8236 -34.3006 447.8483
-20.1823 -33.1717 447.7606
-17.1600 -33.2211 447.7111
-18.5132 -32.7275 447.4237
</Vertices>
<!-- Data values at each vertex of DxL map LAT Isochronal -->
<Map_data number="10">
-25.71685410
-31.93716621
-32.62400055
-30.80163956
-31.13931465
-30.83820915
-29.15049171
-24.14959908
-29.09409142
-26.68566704
</Map_data>
<!-- Color values at each vertex of DxL map LAT Isochronal -->
<Map_color number="13813">
0.4626
0.4458
0.4905
0.4822
0.4896
0.5309
0.6535
0.5323
0.5914
0.5700
</Map_color>
<!-- Color High and Low values -->
<Color_high_low number="2">
-50.8110 -10.0140
</Color_high_low>
<!-- Map_status for each vertex: 0=good, 1=scar (lowV_id), 2=unsampled (beyond InterpDist)-->
<Map_status number="13813">
0
0
0
0
0
0
0
0
0
0
</Map_status>
<Normals number="13813">
0.630414 0.432509 0.644604
0.435386 0.798371 0.415984
0.044542 0.176005 0.983381
-0.282123 -0.250817 0.926012
0.220632 -0.129819 0.966679
-0.067752 -0.160089 0.984775
-0.347585 -0.134141 0.928004
-0.737802 0.404313 0.540536
0.576400 0.757950 0.305408
-0.338783 0.184557 0.922586
</Normals>
<Polygons number="11">
3 10 1
10 2 1
8 5 4
6 5 1
2 7 1
2 9 7
1 5 8
3 1 8
1 7 6
3 4 8
3 4 10
</Polygons>
<!-- Surface of origin for each polygon (indexed from 0): -->
<Surface_of_origin number="11">
1
1
1
1
1
1
1
1
1
1
1
</Surface_of_origin>
</Volume>
</Volumes>
<Labels number="0">
</Labels>
<ObjectMap>
<Rotation>1.000000 0.000000 0.000000 0.000000 1.000000 0.000000 0.000000 0.000000 1.000000</Rotation>
<Translation>0.000000 0.000000 0.000000</Translation>
<Scaling>1.000000 1.000000 1.000000</Scaling>
<MD5Signature></MD5Signature>
</ObjectMap>
</DIFBody>
</DIF>

Respuesta aceptada

Harshendra Shah
Harshendra Shah el 9 de Abr. de 2020
There is an updated version of xml2struct is available.
There was some limitations in the previous versions that has been solved in this version:
1. Solved the issue that when comment is present, other data will be lost.
2. Fixed the " Undefined function 'toCharArray' for input arguments of type 'double'. " issue.
3. Added support for xml string.
I tried using this updated version and it is converting the xml file correctly.
You can also try using xmlread, if it helps in your use case.
I hope this helps.

Más respuestas (0)

Categorías

Más información sobre String Parsing en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by