这些文件可以在 PHP 中进行解析,并在流XMLReader
上进行操作。您拥有的文件的结构是示例性的(查看大约前 3000 个元素):compress.bzip2://
\-mediawiki (1)
|-siteinfo (1)
| |-sitename (1)
| |-base (1)
| |-generator (1)
| |-case (1)
| \-namespaces (1)
| \-namespace (40)
\-page (196)
|-title (196)
|-ns (196)
|-id (196)
|-restrictions (2)
|-revision (196)
| |-id (196)
| |-parentid (194)
| |-timestamp (196)
| |-contributor (196)
| | |-username (182)
| | |-id (182)
| | \-ip (14)
| |-comment (183)
| |-text (195)
| |-sha1 (195)
| |-model (195)
| |-format (195)
| \-minor (99)
\-redirect (5)
文件本身有点大,因此需要相当长的时间来处理。或者,不要对 XML 转储进行操作,而只需通过mysql
命令行工具导入 SQL 转储。该站点上也提供 SQL 转储,请参阅英语维基词典的所有转储格式:
整个文件有点大,有超过 66 849 000 个元素:
\-mediawiki (1)
|-siteinfo (1)
| |-sitename (1)
| |-base (1)
| |-generator (1)
| |-case (1)
| \-namespaces (1)
| \-namespace (40)
\-page (3993913)
|-title (3993913)
|-ns (3993913)
|-id (3993913)
|-restrictions (552)
|-revision (3993913)
| |-id (3993913)
| |-parentid (3572237)
| |-timestamp (3993913)
| |-contributor (3993913)
| | |-username (3982087)
| | |-id (3982087)
| | \-ip (11824)
| |-comment (3917241)
| |-text (3993913)
| |-sha1 (3993913)
| |-model (3993913)
| |-format (3993913)
| \-minor (3384811)
|-redirect (27340)
\-DiscussionThreading (4698)
|-ThreadSubject (4698)
|-ThreadPage (4698)
|-ThreadID (4698)
|-ThreadAuthor (4698)
|-ThreadEditStatus (4698)
|-ThreadType (4698)
|-ThreadSignature (4698)
|-ThreadParent (3605)
|-ThreadAncestor (3605)
\-ThreadSummaryPage (11)