dongwei4444 2019-01-31 00:43
浏览 97
已采纳

如何使用PHP将数据解析为XML文件,这些XML文件的格式不通用且可以更改?

Problem:

I am to build a web-based tool in PHP to help users access information scattered across a collection of XML files that I plan to store data from into tables in MySQL. A lot of examples I see online seem to be based on importing data from a bunch of XML files that all use the same formatting. I do not have that luxury.

How would I be able to parse through XML files that have the following factors?

  • There are multiple categories of XML files in this collection, each having separate formats and types of information that differentiate each category. Ideally, I would create a separate table for each category. However...
  • Additional new categories of XML files could be added to this collection without my knowledge ahead of time.
  • Any existing category could have its format restructured and/or the types of information within could be increased or decreased, also without my knowledge ahead of time.
  • Even among the same category of XML files, there can be older files that have an outdated formatting version.

Expected Results:

Using an example where the collection of XML is about a group of people, if you search for "brown eyes", you get search results listing pages for everyone listed with brown eyes. One of the pages is "Robert". If you click this result, you'll go to a page where all the information from Robert's XML file is displayed (readable formatting to be handled later).

  • 写回答

1条回答 默认 最新

  • dto5637 2019-01-31 01:02
    关注

    you could only create a self-learning parser, which adds new columns to the table whenever it finds new properties in the XML. basically there are two options available: either build up a data model, which at some point in time matches all the records - or stuff the mess into a noSQL database, which does not necessarily make the mess any better. "one size fits all" (stuffing unstructured data into a structured database) is not an option.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 R语言卸载之后无法重装,显示电脑存在下载某些较大二进制文件行为,怎么办
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?
  • ¥15 关于#vue.js#的问题:修改用户信息功能图片无法回显,数据库中只存了一张图片(相关搜索:字符串)
  • ¥15 texstudio的问题,