I would like a very simple example for reading numeric data from a xml file using xml read. I would like the xml file to be something like:
<!-- This is a simple xml file containing data -->
<file>
<data>
<variable1>100</variable1>
<variable2>200</variable2>
</data>
</file>

댓글 수: 4

Rik
Rik 2018년 7월 12일
Please edit your question, currently your example xml is unreadable, so it cannot easily be used in a MWE.
Guillaume
Guillaume 2018년 7월 12일
I've edited the question to make it readable. In the future, use the {}Code button to format code properly.
doc xmlread
shows simple examples that you're requesting.
Bruce McWhorter
Bruce McWhorter 2018년 7월 12일
편집: Guillaume 2018년 7월 12일
Thanks. Yes, I have been reading more on this subject and now understand a lot more.
I needed to at least state the following on the first line of the file: <?xml version="1.0" encoding="utf-8"?>
Some good advice I received is to use the matlab function "xml2struct", which I have done and that seems to do what I needed.

댓글을 달려면 로그인하십시오.

 채택된 답변

Guillaume
Guillaume 2018년 7월 12일

2 개 추천

I would recommend you use xml2struct to save you having to navigate the xml DOM returned by xmlread.
xml = xml2struct(yourxmlfile);
xml.file.data.variable1
xml.file.data.variable2

추가 답변 (0개)

카테고리

제품

릴리스

R2016a

질문:

2018년 7월 12일

편집:

2018년 7월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by