Can I use MySQL LOAD XML LOCAL INFILE if my rows don't have a 'name'?

前端 未结 1 363
独厮守ぢ
独厮守ぢ 2021-01-16 19:39

I have some XML that I am trying to load directly into a MySQL table. I am fairly comfortable with the idea of \"ROWS IDENTIFIED BY\", but I am stuck at the point where I wa

相关标签:
1条回答
  • 2021-01-16 20:22

    As documented under LOAD XML Syntax:

    This statement supports three different XML formats:

    • Column names as attributes and column values as attribute values:

      <row column1="value1" column2="value2" .../>
    • Column names as tags and column values as the content of these tags:

      <row>
        <column1>value1</column1>
        <column2>value2</column2>
      </row>
    • Column names are the name attributes of <field> tags, and values are the contents of these tags:

      <row>
        <field name='column1'>value1</field>
        <field name='column2'>value2</field>
      </row>

      This is the format used by other MySQL tools, such as mysqldump.

    Since your XML is in none of these supported formats, you must use some other tool to parse it.

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