Parsing XML with PHP's simpleXML

前端 未结 5 1454
北恋
北恋 2020-12-11 10:23

I\'m learning how to parse XML with PHP\'s simple XML. My code is:



        
5条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-11 11:09

    this is general example

    foreach ($library->children() as $child)
    {
       echo $child->getName() . ":\n";
       foreach ($child->attributes() as $attr)
       {
        echo  $attr->getName() . ': ' . $attr . "\n";
      }
    foreach ($child->children() as $subchild)
    {
        echo   $subchild->getName() . ': ' . $subchild . "\n";
    }
       echo "\n";
    }
    

    for more information check this : http://www.yasha.co/XML/how-to-parse-xml-with-php-simplexml-DOM-Xpath/article-1.html

提交回复
热议问题