SimpleXML get node value

后端 未结 3 618
清歌不尽
清歌不尽 2020-12-11 02:11

Say I have this following XML structure:


some value<
3条回答
  •  温柔的废话
    2020-12-11 02:51

    Variant for xpath (Also how to get content of node having dashes in name):

     
    some value another value
    $xml = simplexml_load_string($content);
    $node_value= (string)$xml->xpath('parent/child-1')[0];
    

    result of $node_value:

    "some value"

提交回复
热议问题