使用Matlab从.XML文件访问数据 [英] Accessing data from .XML file with Matlab

查看:470
本文介绍了使用Matlab从.XML文件访问数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 .XML 文件,如下所示:

I've got a .XML file that looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Comments</key>
<string></string>
<key>DataSummary</key>
<dict>
    <key>AreaCM2</key>
    <real>2.77</real>
    <key>Dev</key>
    <real>9.48</real>
</dict>
<key>DataValues</key>
<array>
    <real>81</real>
    <real>85</real>
</array>
<key>ROIPoints</key>
<array>
    <string>{65.7414, 58.2929}</string>
    <string>{65.7388, 58.4421}</string>
</array>
</dict>
</plist>

我想使用MATLAB 访问DataValuesROIPoints .

I'd like to access DataValues and ROIPoints using MATLAB.

我发现提取ROIPoints的方式非常牵强,它的工作方式如下:

I found quite a far fetched way of extracting ROIPoints which works like this:

DOMnode = xmlread(pathofxmlfile);
i       = DOMnode.getDocumentElement;
f       = char(i.getTextContent);

f是包含所有文本"内容的字符串:

f is a string containing all the "text" contents:

f = CommentsDataSummaryAreaCM22.77Dev9.48DataValues8185ROIPoints**{65.7414, 58.2929}{65.7388, 58.4421}

由于ROIPoints用大括号括起来,所以我可以操纵字符串以提取它们.

Since ROIPoints are enclosed in curly brackets, I can manipulate the string in order to extract them.

不幸的是,DataValues被水平连接(8185),我无法分别提取它们.

Unfortunately, DataValues get horizontally concatenated (8185) and I cant extract them individually.

有什么秘诀吗?

推荐答案

请查看 xml_read .它将读取您的xml并将其作为结构输出(遵循xml树).不过对于较大的XML来说可能会很慢.

Please check out xml_read on matlab central. It will read your xml and output it as a struct (following your xml tree). It might be slow for larger XML's though.

这篇关于使用Matlab从.XML文件访问数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆