<?xml version="1.0" encoding="utf-8"?>
<comments>
<row Id="1" PostId="1" score="3" Text="Maxis uses this in The Sims when clicking on your person to perform actions. ex: call->friend->[friends name]" CreationDate="2010-08-09T19:52:30.690" UserId="12" />
<row Id="2" PostId="1" score="1" Text="Here are some examples: http://en.wikipedia.org/wiki/Pie_menu#Notable_implementations" CreationDate="2010-08-09T19:54:54.007" UserId="31" />
<row Id="3" PostId="9" score="13" Text="How about making it short and with less steps :)" CreationDate="2010-08-09T19:55:57.670" UserId="35" />
<row Id="4" PostId="3" score="1" Text="10 sec seems like an awful lot when you are browsing." CreationDate="2010-08-09T19:57:57.057" UserId="32" />
...
</comments>
我环顾四周,发现this slightly related question,但是它的行看起来像这样:
<row>
<field name="personal_number">539</field>
<field name="firstname">Name</field>
<field name="lastname">Surname</field>
<field name="email">email.domain.com</field>
<field name="start_time">2011-04-02 13:30:00</field>
<field name="end_time">2011-04-02 18:15:00</field>
<field name="employee_category">1,2,4,5,22,37,38,39,41,43,44</field>
</row>
在每一行中,每个字段都有一个XML元素-而不是像我一样,每行都具有一个指定为属性的内容的XML元素.
如何将其导入MysqL?我几乎可以使用任何技术,但是我希望远离需要Windows的任何技术.
解决方法:
有关LOAD XML INFILE语句支持的XML格式,请参见http://dev.mysql.com/doc/refman/5.6/en/load-xml.html.
手册页指出:
the import routine automatically detects the format for each row and interprets it correctly. Tags are matched based on the tag or attribute name and the column name.
支持的一种格式与您的格式类似-将列存储为< row>的属性.元件.
如果您需要将XML数据转换为MysqL的LOAD XML支持的格式之一,则可以使用xsltproc.
我假设如果您的XML数据的格式设置不完全一致,那么它将使LOAD XML INFILE混乱.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。