Automated XML data mapping
Excuse me if my question might seem ignorant.
My problem:
I'm developing an applicatio开发者_如何学Pythonn using a product API. I currently retrieve the Prices, etc dynamically, but I am now interested in storing the price changes in my Mysql database.
I am stuck here, because I cannot logically imagine how this is possible,
The data I currently retrieve is in XML format.
I use PHP.
What I am looking for is advice or suggestions as to how I would even begin to start planning this project.
Thanks in advance for any comments/advice or suggestions.
Whatever information you're getting from the api, could turn into columns, and whatever you're putting into the api could define your rows, for example: Say I have an api that gives me a first name, last name and age, given a phone number.
That could be turned into a database that contains the columns "FirstName" "LastName" "Age" "PhoneNumber". Depending on the type of data that you're storing you would need to choose a datatype for each column. ( http://dev.mysql.com/doc/refman/5.0/en/data-types.html )
Then you can start making calls to the api, say input "123-456-7890", and get back "John" "Doe" 23. Then you insert that row into your database.
Depending on what the actual xml returned is, it could already have reasonable column names for you. Or if the xml is nested too deep it could bring more problems.
精彩评论