xml:lang parse in PHP

前端 未结 5 1308
余生分开走
余生分开走 2020-12-10 19:05

  
    
      
        FW&         


        
5条回答
  •  借酒劲吻你
    2020-12-10 19:22

    XPath has a special construct for dealing with xml:lang attribute:

    $xml = new SimpleXMLElement($strXML);
    $data = $xml->describe->data[0];
    $elCode = $data->xpath("code[lang('en')]"); // returns array of SimpleXMLElement
    assert(count($elCode)==1);
    $code_en = (string) $elCode[0];
    

    P.S. greetings to the Sirena ;)

提交回复
热议问题