mysql - Import parts of a .xml to sql database using php -
i'm trying import several parts of .xml file mysql database using php. parts want import marked specific keyword. possible specify import or research keywords before importing ?
this small extract of xml file:
<?xml version="1.0" encoding="iso-8859-1" standalone="no"?> <kl_plan> //this part want import: <pl> <pl_tag>day1</pl_tag> <pl_stunde>lesson1</pl_stunde> <pl_un>8</pl_un> <pl_fach>subject1</pl_fach> <pl_fachori>subject1</pl_fachori> <pl_klasse>class1</pl_klasse> <pl_lehrer legeaendert="legeaendert">hr</pl_lehrer> //"geaendert" keyword <pl_lehrerori>teacher1</pl_lehrerori> <pl_raum>room1</pl_raum> </pl> //this information (with normal format) don't want import: <pl> <pl_tag>day</pl_tag> <pl_stunde>lesson</pl_stunde> <pl_un>36</pl_un> <pl_fach>subject</pl_fach> <pl_fachori>subject</pl_fachori> <pl_klasse>class</pl_klasse> <pl_lehrer>teacher</pl_lehrer> <pl_lehrerori>teacher</pl_lehrerori> <pl_raum>room</pl_raum> </pl> </kl_plan>
there different variations of keyword (like: legeaendert, rageaendert, fageaendert)
i have code imports whole .xml file. doesn't me because there unnecessary information in xml.
hi can use simplexml_load_string — interprets string of xml object
little example of use
$string = <<<xml <?xml version='1.0'?> <document> <title>forty what?</title> <from>joe</from> <to>jane</to> <body> know that's answer -- what's question? </body> </document> xml; $xml = simplexml_load_string($string); print_r($xml);
example output:
simplexmlelement object ( [title] => forty what? [from] => joe [to] => jane [body] => know that's answer -- what's question? )
try , luck ...!!!
Comments
Post a Comment