Access data from .XML file using Matlab

I have 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> 

I would like to access DataValues and ROIPoints using MATLAB .

I found a rather remote way to extract ROIPoints that works as follows:

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

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

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

Since ROIPoints enclosed in braces, I can manipulate the string to extract them.

Unfortunately, DataValues is horizontally concatenated (8185), and I cannot extract them individually.

Any tips?

+4
source share
1 answer

Please check out xml_read on the central Matlab server. It will read your xml and output it as a structure (after your xml tree). This can be slow for large XML though.

+3
source

Source: https://habr.com/ru/post/1494938/


All Articles