Storing .xml information in matlab

Hello Everyone, I am trying to read rss feed in .xml file format. For further processing that information, I need to store it in some database, so that I can use it later. I tried using datastore function available in matlab but I was not able store .xml data in it.
Could anybody help me by providing more information on how can I store xml data?; and what other ways I can use.

10 Comments

madhan ravi
madhan ravi on 6 Nov 2018
Edited: madhan ravi on 6 Nov 2018
show us your code so that we know how you are trying to store the datas
"I tried using datastore function available in matlab but I was not able store .xml data in it...."
It's hard to say what you did wrong, if you don't show us what you did. Saying that, I don't really see what a datastore has got to do with I need to store it in some database, particularly since datastores are just for reading.
What do you want to store in your database anyway? The raw xml? Hopefully not. What backend are you using for your database and have you decided on the database schema?
Hello Madhan and Guillaume,
Thank you for the quick response. As I am new to Matlab, I thought I would be able to store data using datastore function.
I am trying to read the calendar information which is available through RSS feed
Reading infromation using webread command,
dss = webread('https://www.tu-chemnitz.de/tu/termine/tu-heute.rss/.xml')
now I have to store this information in some database so that I can use it for further processing the data. This is the information of the events which is going to happen in few days, so every-time there will be the new information available after few days. I need to collect those information regularly and store it in the database so I can use that information in future.
I am not much aware about how can I store this information in some database using matlab.
You haven't answered any of my questions. What do you want to store in your database? The raw xml you get from webread. The result of the xml parsing (which you'll parse as what? The DOM object returned by xmlread? A structure as per Stephan's answer?)?
What database are you planning to use? Are you even planning to use a database or are you just losely using the term for just storing something somewhere?
Your question leaves a lot of room for interpretation. That makes it difficult to give you an appropriate answer. Please try to use unique terms that describe exactly what you want to achieve. My understanding of your question is, how to convert .xml data to a Matlab data type to work with. But it easily can be understood in another way. Please clarify.
Hello Guillaume and Stephan,
I apologies for not being clear, actually I am new to xml and storage so still understanding the terminology and concept. I am sorry for that :(
I will start from beginning,
1. Using webread I am reading the content from the URL, that content is the raw xml content and I want to store it somewhere. There will be a new content available every week lets say on that URL and I need to read and store that content every time to some data base for further processing the data.
2. Most probably I will parse it as structure as Stephan mentioned before
3. So my first task here is to store raw xml content I am getting from URL to some storage (database), as new content will be updated every week and old content will be vanished on URL.
I was referring some websites and found out that it is possible to do it using mysql, could you please let me know that is it possible to use mysql over here to create the database to store the contents which I am getting from URL? Please let me know, if it is still not clear.
What we normally call a database is normally used to store structured data. You could certainly store your raw xml in a databse (mysql included) but in my opinion that would be a total waste of time and effort. In any case, if you use a database, you need to come up with a data model for your database. At a minimum a record would have the date/time received or at least some sort of ID, and the xml.
Storing the decoded xml into a database would make a lot more sense, then the data model of your database would match whatever data model is encoded in your xml.
Hello Guillaume, Thank you so much for the guidance, I will decode the xml information first and then store it to the database in mysql.
KAE
KAE on 18 Dec 2019
Edited: KAE on 18 Dec 2019
Guillame, I have the same problem: I want to read in a large XML file containing semi-structured data, pick the fields that are useful to me, and organize it so I can do some analysis. I would like to try your solution of creating a database to put the organized records into, but I am not sure where to start. I have a trial of the Database toolbox, so I could use that. Would I need to first create the database in mysql? It sounds like I can do it directly from Matlab here but I have to admit I am not clear how this all would look overall.
Note: I'm far from an expert on databases. I can write my own SQL queries and have created databases in sqlite, SQL server and (gasp!) Access and accessed some of these with matlab but it's been a while. Also, I don't have the database toolbox so I did my own communication with the database drivers.
Your question is very open ended. First question is: do you actually need a database? Wouldn't matlab tables be enough? If you do need a relational database, then the first thing you need to do is define a schema for your database. What tables, what relationship for these tables. You'd base that on the XML structure in this case. I've always done that design by hand (or with the built-in database editor that comes with the database), I've no idea what the database toolbox offers in this regard.
Nowadays, you've also got the NoSQL databases which may be more appropriate for semi-structured data. It's not something I've ever worked with.

Sign in to comment.

 Accepted Answer

Stephan
Stephan on 6 Nov 2018
Edited: Stephan on 6 Nov 2018
Hi,
check this@FEX - there is also an improved version available.
Best regards
Stephan

More Answers (0)

Asked:

on 6 Nov 2018

Commented:

on 18 Dec 2019

Community Treasure Hunt

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

Start Hunting!