5

I'm not sure if this is possible, but figured I'd ask and see if I can get any info.

As the title suggests, I have an XML file with thousands of lines. I also have its associated XSD schema file.

I was wondering, is it possible for me to convert this data into a MySQL database without manually specifying the XPath stuff?

For example, is it possible for a Java or Python or whatever program to analyse the XML structure, based on the XSD, extract the table columns, and populate it with data?

I tried using PHPMyAdmin to import my XML file, but it didn't work and said there was a problem, which I think was related to the fact that it couldn't create the columns. As far as I know, it can handle CSV files better, so that's another option for a 2 stage conversion.

Thanks.

Paul Sweatte
  • 24,148
  • 7
  • 127
  • 265
eoinzy
  • 2,152
  • 4
  • 36
  • 67
  • can you post an exemple of an XML and the table structure of the table thats supose to recive the data? – Puggan Se Jul 17 '12 at 21:48
  • Thats exactly my point! I am looking for a way that I can automatically create a table structure from the XML/XSD. I don't want to worry about the table structure. I want to be able to supply only the XML and XSD, run the software/code, and be given a DB populated with the XML data. – eoinzy Jul 17 '12 at 21:51
  • so if we give this code a XML-file, for exemple a XHTML-document, its going to create alot of tables from guesses, to store all the data from the XHTML file? – Puggan Se Jul 17 '12 at 21:55
  • Yes, so if you have a field `John` it will create a column called `Name` and populate a row with the data `John`. I'm really just curious if some software is already out there and easily accessible, otherwise I will have to write my own code to consume my XML file. – eoinzy Jul 18 '12 at 14:56
  • How are you going to handle the depth of an XML, where do you store: `

    Hello

    `
    – Puggan Se Jul 18 '12 at 14:59
  • See this answer http://stackoverflow.com/questions/403420/convert-xsd-into-sql-relational-tables and google "generate sql xsd" – David W Jul 19 '12 at 14:11

2 Answers2

3

Try XMLPipeDB for building relational databases from XSD files.

Melroy van den Berg
  • 2,697
  • 28
  • 31
1

Use XMLImport to load the XML with XSD into Excel, save as CSV or format into the desired XML format such as Wordpress, then import into MySQL.

Paul Sweatte
  • 24,148
  • 7
  • 127
  • 265
  • @eoinzy Hi eoinzy, I'm in the same position as you were right now. Did this solution work for you? Any tips you might have found along the way you could give me? Thanks – jskidd3 Feb 25 '14 at 12:26
  • It was a long time ago. I think I wrote a once off python parser for the XML file, and converted it to JSON. – eoinzy Feb 26 '14 at 18:09