parsing XML file with defined format

20 visualizaciones (últimos 30 días)
michael
michael el 17 de Ag. de 2017
Respondida: Guillaume el 27 de Ag. de 2017
Hello,
I have following xml file:
<message Name="abc">
<element name=XYZ enumType="enum1">
<enumeration>
<enum name="YES" value="0"/>
<enum name="no" value="1"/>
</enumeration>
<element name=ZYX enumType="enum1">
<enumeration>
<enum name="YES" value="0"/>
<enum name="no" value="1"/>
</enumeration>
</message>
I'd like to parse this file and convert it to some other language. In order to do so, I need to configure enum name (like variable name), where is the only location of the name is part of the element.
When reading the file, I can see that there are 2 elements and 2 enums, where the latter are without any name variable name which I can use.
Any suggestion how to parse this file?

Respuestas (2)

Guillaume
Guillaume el 27 de Ag. de 2017
There is no need for any toolbox to parse xml in matlab. xmlread will do that for you. If you want an easier output than the DOM, then the file exchange xml2struct will do the job.
So reading the xml is easy. However, creating enum types from that xml is not going to be that easy. enum types are classes in matlab, so you'll have to create a m file just for that enum.
What you are trying to do is deserialise some data together with their type. To be honest, Matlab is not well suited for that.

John BG
John BG el 17 de Ag. de 2017
  3 comentarios
John BG
John BG el 18 de Ag. de 2017
michael
michael el 27 de Ag. de 2017
Why Matlab coder?

Iniciar sesión para comentar.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by