MATLAB Answers

Read specific value from XML-file

1 view (last 30 days)
Marc Gebhardt
Marc Gebhardt on 6 May 2021
Edited: Fangjun Jiang on 6 May 2021
Hi guys,
my question is about the reading of information from an xml-file of only a special type of object
Example part of XML-file:
<cim:Car rdf:ID="_00c7c220-2f78-4eb0-80fd">
<cim:Equipment.BaseGroup rdf:resource="#_29355f3f-035d-494e-8549" />
<cim:Car rdf:ID="_01281464-7eca-43db-aca9">
<cim:Equipment.BaseGroup rdf:resource="#_29355f3f-035d-494e-8549" />
<cim:Bike rdf:ID="_02de5fa9-368e-4d5d-9a2f">
<cim:Equipment.BaseGroup rdf:resource="#_29355f3f-035d-494e-8549" />
In this example, there are vehicles listed. Some cars and a bike. For example, i want to read out the names ("") but only from all objects out the the group Car. The result should be a cell, with size (number of elements of type car x 1) with the names in.
How can I do this?

Answers (1)

Fangjun Jiang
Fangjun Jiang on 6 May 2021
The short answer is to use xmlread(). I've done it before. The actual code depends on the schema.
You may also try xml2struct(). It seems much easier.
Marc Gebhardt
Marc Gebhardt on 6 May 2021
Then let us leave this kind of general answers please.
Just write one command, which lists the names for this easy example withput a loop over all elements.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!