自动 XML 数据映射
如果我的问题看起来很无知,请原谅。
我的问题:
我正在使用产品 API 开发应用程序。我目前动态检索价格等,但我现在有兴趣将价格变化存储在 Mysql 数据库中。
我被困在这里,因为我无法从逻辑上想象这是怎么可能的,
我当前检索的数据是 XML 格式。
我使用PHP。
我正在寻找的是关于我如何开始规划这个项目的建议或建议。
预先感谢您的任何意见/意见或建议。
Excuse me if my question might seem ignorant.
My problem:
I'm developing an application 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
无论您从 api 获取什么信息,都可以转换为列,并且您放入 api 的任何信息都可以定义行,例如:
假设我有一个 api,它可以给我提供名字、姓氏和年龄以及电话号码。
可以将其转换为包含“FirstName”“LastName”“Age”“PhoneNumber”列的数据库。根据您存储的数据类型,您需要为每列选择数据类型。 ( http://dev.mysql.com/doc/refman/ 5.0/en/data-types.html )
然后您可以开始调用 api,输入“123-456-7890”,然后返回“John”“Doe” 23.然后插入该行进入您的数据库。
根据实际返回的 xml 内容,它可能已经为您提供了合理的列名称。或者如果 xml 嵌套得太深,可能会带来更多问题。
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.