Mysql
 SQL >> Datenbank >  >> RDS >> Mysql

Eine XML-Datei einlesen und die Daten in MySQL speichern

Ein Blick auf simpleXML load-string oder load-file lohnt sich. Damit lassen sich die XML-Inhalte parsen und die benötigten Werte herausziehen. Zum Beispiel (aus dem PHP-Handbuch):

<?php $string = <<<XML <?xml version='1.0'?> <document> <title>Forty What?</title> <from>Joe</from> <to>Jane</to> <body> I know that's the answer -- but what's the question? </body> </document> XML; $xml = simplexml_load_string($string); var_dump($xml); ?> 

Das erzeugt:

SimpleXMLElement Object ( [title] => Forty What? [from] => Joe [to] => Jane [body] => I know that's the answer -- but what's the question? ) 

Berichte, wie es läuft.