php - How to import XML feed with multiple images -


i have xml feed ...

<products>   <product>     <title>mini piscina</title>     <description>mini piscina penru copii pana la 6 ani.</description>     <price>22.00</price>     <images>       <image1>produs_1402038969.jpg</image1>       <image2>produs_1402382460.jpg</image2>     </images>   </product> </products> 

... , part of script ...

$xml=simplexml_load_file("../feed/feed") or die("error: cannot create object"); $partener = 'toys';  foreach($xml -> product $row) {     $magazin = $partener;     $titlu = $row -> title;     $descriere = $row -> description;     $pret = $row -> price;     $imagine1 = $row -> images1;     $imagine2 = $row -> images2;      $sql = "insert toys (magazin,titlu,descriere,pret,imagine1,imagine2)             values ('$magazin','$titlu','$descriere','$pret','$imagine1','$imagine2') ";         mysqli_query($conn, $sql); } 

... result is: title, descrition , price imported image1 , images2 can not imported. why? i'm beginner. please, can me?

the 2 images not children of product grandchildren. simply, add parent images-> path obtain values:

foreach($xml -> product $row) {     $magazin = $partener;     $titlu = $row -> title;     $descriere = $row -> description;     $pret = $row -> price;      $imagine1 = $row->images->image1;     $imagine2 = $row->images->image2;      $sql = "insert toys (magazin,titlu,descriere,pret,imagine1,imagine2)             values ('$magazin','$titlu','$descriere','$pret','$imagine1','$imagine2') ";     mysqli_query($conn, $sql); } 

Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

java.lang.NoClassDefFoundError When Creating New Android Project -

Decoding a Python 2 `tempfile` with python-future -