2

Is there a way to convert an xml file to a mysql table as a sql statement using php?

I'm open to any PEAR packages you know of.

1
  • reference for myself mysql xml Commented Jul 14, 2011 at 17:45

2 Answers 2

3

Actually, parsing XML to MySQL is a direct task and need a lot customization based on your XML structure. I suggest you to use SimpleXML to parse XML and insert into MySQL using PHP's MySQLi classes.

Sign up to request clarification or add additional context in comments.

1 Comment

could you post a quick sample I just want to see a way to go through a certain number of records and input them as mysql
1

there are several packages available to read XML data in PHP (parsing XML). You can write simple code to insert the same in mysql with your custom fields.

I used ParseXml.class.php from phpclasses.org

The code should use like below.

require './ParseXml.class.php';

 $xml = new ParseXml();
 $xml->LoadFile("./test.xml");
 //$xml->LoadString($xmlString);
 //$xml->LoadRemote("http"//www.yourdomain.com/dir/filename.xml", 3);
 $dataArray = $xml->ToArray();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.