You are here:  » xml to mysql question


xml to mysql question

Submitted by frankiegiotta on Fri, 2007-08-17 09:29 in

Dear David,

we are thinking about buying this utility but first we need to be sure that it does what we are looking for. We are working with XML and what we need to do is the following example;

<album>
<AlbumArtist>Interactive</AlbumArtist>
<AlbumTitle>The Best Of Interactive</AlbumTitle>
<AlbumArtistURL>http://www.soehne-mannheims.de</AlbumArtistURL>
<AlbumProductGRID></AlbumProductGRID>
<AlbumEAN_UPC>0090204372324</AlbumEAN_UPC>
<CoverFile>
<CoverFileType>JPG</CoverFileType>
<CoverSize>11701</CoverSize>
<CoverFileURI>0090204372324_300.jpg</CoverFileURI>
<CoverFileMD5>6d3c85d7effb762ca64308b55279ac27</CoverFileMD5>
</CoverFile>

what we need to do is this, the first field is the xml tag, the second is the field where we want the tag to be placed and the third is the table corresponding to that tag (in the database where we have to import this we have already created a table with this structure)

"AlbumMediaType ";"AlbumMediaType ";"album"
"AlbumLabelOrderNumber ";"AlbumLabelOrderNumber ";"album"
"AlbumGenre2 ";"AlbumGenre2 ";"album"
"AlbumGenre ";"AlbumGenre ";"album"
"AlbumEAN_UPC ";"AlbumEAN_UPC ";"album"
"AlbumDigitalReleaseDate ";"AlbumDigitalReleaseDate ";"album"
"AlbumDigitalCancellationDate ";"AlbumDigitalCancellationDate ";"album"
"AlbumArtistURL ";"AlbumArtistURL ";"album"
"AlbumArtist ";"AlbumArtist ";"album"
"album ";"album ";"album"
"CoverFileURI ";"CoverFileURI ";"cover"
"CoverSize ";"CoverSize ";"cover"

we have thousands of these XML and we have to import them into a mysql database, is this the correct utility for us?

Thank you

David and Frankie

Submitted by support on Fri, 2007-08-17 09:46

Hi,

Firstly, please note that Magic Parser is only a parser library, it does not have any code to do with inserting records into MySQL, so all the code to do that would need to be written in addition to your Magic Parser code.

The parser would almost certainly work with your source XML. You can confirm this by using the demo tool on this website - you can upload your XML and confirm that Magic Parser interprets the records correctly. After that, it would be a case of processing your formatting file (which you could also use Magic Parser for, if you wished), and then constructing the necessary SQL statements during the parse of the XML source document.

Are you in a position to be able to develop the additional MySQL code, or were you looking for a utility that would assist with this also?

Cheers,
David.

Submitted by frankiegiotta on Fri, 2007-08-17 10:32

Dear David,
thank you for your rapid response. We are trying the demo for this operation to see if this is ok.
As for the other database problem, it would also be great to have a utility for doing this, can you help us here also?

Thank you

David and Frankie

Submitted by support on Fri, 2007-08-17 11:01

Hi David,

You are unlikely i'm afraid to come across any utility that will be compatible with your specific requirement in this case. Mainly because, once familiar with the MySQL code required to do what you want there is usually no quicker option than to write your own code.

My recommendation would be to get familiar with the MySQL code required to do what you want before starting on the parser side of things, perhaps by following one of the PHP / MySQL guides available on the net - and I would recommend as a starting point the PHP documentation itself as there are plenty of examples there and in the comments that should help point you in the right direction....

http://uk.php.net/manual/en/ref.mysql.php

Cheers,
David.