Import XML with content specified as attributes into a MySQL table?

后端 未结 1 956
萌比男神i
萌比男神i 2021-01-24 07:11

I have an XML file that looks like this:



  

        
相关标签:
1条回答
  • 2021-01-24 07:55

    See http://dev.mysql.com/doc/refman/5.6/en/load-xml.html for the XML formats supported by the LOAD XML INFILE statement.

    The manual page states:

    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.

    One of the formats supported does resemble yours -- storing columns as attributes of a <row> element.

    If you need to transform your XML data into one of the formats supported by MySQL's LOAD XML, you could probably use xsltproc.

    I would assume that if your XML data isn't formatted with perfect consistency, that it will confuse LOAD XML INFILE.

    0 讨论(0)
提交回复
热议问题