Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

importing xml to a database table

Status
Not open for further replies.

sridharvarma

Programmer
May 15, 2012
1
i hvae an xml file,which was exported by phpmyadmin.Now i want to import that xml file to a database table with "load xml" or using php..please help me...

Load xml is inserting the xml values of only one column...

Here is my xml file:

<?xml version="1.0" encoding="utf-8"?>
<!--
- phpMyAdmin XML Dump
- version 3.3.9
- -
- Host: localhost
- Generation Time: May 15, 2012 at 06:55 AM
- Server version: 5.5.8
- PHP Version: 5.3.5
-->

<pma_xml_export version="1.0" xmlns:pma=" <!--
- Structure schemas
-->
<pma:structure_schemas>
<pma:database name="polls" collation="latin1_swedish_ci" charset="latin1">
<pma:table name="sample">
CREATE TABLE `sample` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(250) NOT NULL,
`sal` int(11) NOT NULL,
`depat` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1;
</pma:table>
</pma:database>
</pma:structure_schemas>

<!--
- Database: 'polls'
-->
<database name="polls">
<!-- Table sample -->
<table name="sample">
<column name="id">1</column>
<column name="name">siddu</column>
<column name="sal">25000</column>
<column name="depat">10</column>
</table>
<table name="sample">
<column name="id">2</column>
<column name="name">raju</column>
<column name="sal">25000</column>
<column name="depat">14</column>
</table>
<table name="sample">
<column name="id">3</column>
<column name="name">prakash</column>
<column name="sal">28000</column>
<column name="depat">15</column>
</table>
<table name="sample">
<column name="id">4</column>
<column name="name">goutham</column>
<column name="sal">20000</column>
<column name="depat">20</column>
</table>
<table name="sample">
<column name="id">5</column>
<column name="name">manoj</column>
<column name="sal">98000</column>
<column name="depat">12</column>
</table>
</database>
</pma_xml_export>


And my xml query is:

LOAD XML LOCAL INFILE 'PATH OF XML FILE' INTO TABLE 'T_NAME' rows IDENTIFIED BY '<table>';
Then it is inserting only the 'id' column values and the second column values are 'depat' only...
Y i am getting like this.

Thank you in advance....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top