Getting Data from inside a node in XMl with PHP

前端 未结 2 1806
忘了有多久
忘了有多久 2021-01-16 10:44

So im not sure what or how to really describe what i need but hopefully someone will understand.

single element of the total xml file looks like this:

for         


        
2条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-16 10:58

    try this

    $xml = simplexml_load_file("books.xml") 
       or die("Error: Cannot create object");
    
      foreach($xml->children() as $books){
    foreach($books->children() as $book => $data){
      echo $data->id;
      echo $data->title;
      echo $data->author;
      echo "
    "; }

    }

提交回复
热议问题