Reading values from xml file
361 views (last 30 days)
I've read around a bit and cant seem to get this to work. I am trying to read out a specific value from stereotyped xml files. The xml files look like this: http://i.imgur.com/uSEQt.png and I am trying to access the second "Frame relativeTime" value from the file for use in a data analysis pack I'm writing. There are many "Frame realtive time" entrees in the xml file but I am just trying to pull the second value and save it as a variable."
Pritom Kumar Saha on 3 Aug 2021
S = readstruct("abcd.xml")
it works on my matlab version.
It should work on matlab 2020b or higher version.
Thomas on 27 Mar 2012
Try this from the file exchange. I have found it to be useful
example : here is sample.xml
<title>XML Developer's Guide</title>
<description>An in-depth look at creating applications
<description>A former architect battles corporate zombies,
an evil sorceress, and her own childhood to become queen
of the world.</description>
If I have to find the price of the second book:
c=xml2struct('sample.xml') % use function from file exchange
Turlough Hughes on 14 May 2021
filename = 'students.xml';
T = readtable(filename);
You can also select specific variables or attributes to read via detectImportOptions (or XMLImportOptions) - first get the opts and display the variable names:
opts = detectImportOptions(filename);
then select the variable names that you want - let's say you want FirstNameAttribute, LastNameAttribute and Age, that would go as follows:
opts.SelectedVariableNames = opts.VariableNames(2:4);
T = readtable(filename,opts)
Image Analyst on 27 Mar 2012
Did you try xmlread()? Can you show your code and maybe upload your xml file and m-file somewhere so people can try something if they want to?