Question : How do I import an xml file into a mysql database using php?

Hi,

Could anyone please provide me with a PHP script which can import the contents from the attached xml file into the respective fields of the book table in the attached database; 'book1'?

For the most part, I have tried to keep the columns in the book table of the database identical to the tag names in the xml file. However there were a few tags in the xml file, such as  <IDValue> which appeared under the <ProductIDType> tags for both the main product as well as the Related Product. In both instances where <IDValue> appears I have used the following column names in the database to distinguish which record should be imported.
ProductIDTypeIDValue1 char(10),
RelationProductIDValue char(13),

Concerning the main product, and not the related product information in the xml file;
the <IDValue> data for <ProductIDType>02</ProductIDType> has a maximum of 10 characters and
the <IDValue> data for <ProductIDType>03</ProductIDType> and <ProductIDType>15</ProductIDType> has a maximum of 13 characters.
The <IDValue> data for <ProductIDType>03</ProductIDType> should be imported into the primary key column of the books table.

Please note also that there are some book records where there is no data for the <IDValue> of <ProductIDType>02</ProductIDType>
 
Finally, is it possible to provide a solution using PHP XML Expat Parser.

Am I correct in thinking that the PHP XML Expat Parser is much more efficient that the PHP SimpleXML.
I wish to design the database so that it can import a very large number of books. (around 100,000).  
Attachments:
 
Creates book database
 
 
XML file to be imported into mysql database.
 

Answer : How do I import an xml file into a mysql database using php?

There are many SQL Server operations that use tempdb to perform sorts and things like that.  Tempdb may bloat to very large sizes.  Restarting SQL Server will shrink tempdb since it's recreated every time SQL starts.  However, this may not be an option in your environment.

Best practice is to put tempdb on a separate disk and make sure it's adequately sized for your day to day operations.

FWIW, temp tables should be automatically destroyed when the connection that created them is dropped.  Table variables are good if you have the memory to support them.
Random Solutions  
 
programming4us programming4us