1

I have a question. Does anyone have a working php script which can parse a XML file to a sql database? I have searched for some scripts and didn't find anything what looks like I can edit it to my needs.

Any help would be great!

3 Answers 3

2

Parse the XML using simplexml and extract the data of your interest from the XML file and insert into MySql using functions listed here.

Give it a try. Its not that difficult and you'll learn a lot.

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

1 Comment

haha.. I dont know how to do this, isn't there a program what can help me do this?
0

It is not a PHP solution, but you can extract values from XML directly into mySQL:

http://dev.mysql.com/doc/refman/5.1/en/xml-functions.html

Of course, if this is something you will need to do often, you can always fall back to what bzabhi have said.

1 Comment

Actually, this does have PHP code to parse the XML file. Heh.
-1

Why not write one from scratch? Not that hard.

2 Comments

I guess a couple of pointers as to how to do this wouldn't have gone amiss here ;-)
Recommend a tutorial "XPath in SimpleXML" at dimuthu.org/blog/2008/09/30/xpath-in-simplexml. You can parse an XML file with regex instead of XPath if you like. After parsing the XML with XPath or regex, you can design a database table according to the relevant fields and import the extracted fields into the table.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.