|
|
|
|
|
I have been trying to use this for quite a while, but i just cant understand how to retrieve data from a .XML file in MATLAB. I have an XML file with 2 important variables i need to retrieve the value for. These are 'A' and 'B'. There are many different values for 'A' and 'B' and i would like to parse the .XML file to save all values for 'A' are saved into an array and all values for 'B' are saved into an array. I have read a tutorial but i still cant figure it out. Any help would be much appreciated. Thanks, |
#21 Lucy Member Posted 6 months ago |
|
% Presuming the variables are stores as elements, and the file is like this: % Read the xml file into memory: docNode = xmlread( 'insert_your_filename_here.xml' ); % Then you just use the JAVA DOM (http://java.sun.com/j2se/1.4.2/docs/api/org/w3c/dom/Element.html) ANodeList = docNode.getElementsByTagName('A'); % returns a reference to all the A elements, i.e. everything in the xml with this pattern .. %Iterate over the node list to read the values of A % of course, everything you read is a string, so if they are numeric variables, you need to use str2double() to make them numeric |
#22 pmacaodh Member Posted 6 months ago |
|
By the way, you can copy the above into Matlab as is to try it out. Just change the filename and ensure it is in your current working directory. Of course, this message board interpreted my example XML elements as a HTML 'A' hyperling tag. The example was meant to look like so: <xml> ...and so on. |
#23 pmacaodh Member Posted 6 months ago |
|
Hello, I have to design a program in Matlab to calculate different plots from XML template. I have read about this and I am sure that the first step is to use 'xmlread'. I have found some functions like .getElementsByTagName but I am not sure how to manage because I have never programmed in Java and I don't know how to read all the variables that I have in my xml. Also, I don't know how to visualize in Matlab this information. If someone can help, please, it would be really useful for me. |
#24 anna Member Posted 5 months ago |
| RSS feed for this topic |
You must log in to post.
| Tags:
|
| © 2009 Anil Kandangath. All posts are owned by the whoever posted them. Share your knowledge. |
| The Math Root is proudly powered by bbPress.. This site is not affiliated with The MathWorks™ or Wolfram Research. // Theme by Mike Lothar |