Getting the text portion of a node using php Simple XML

前端 未结 7 2164
臣服心动
臣服心动 2020-12-03 18:39

Given the php code:

$xml = <<
This is a link Title with some text following it.
7条回答
  •  不思量自难忘°
    2020-12-03 19:36

    Try this:

    $parser = new SimpleXMLElement($xml);
    echo html_entity_decode(strip_tags($parser->asXML()));
    

    That's pretty much equivalent to:

    $parser = simplexml_load_string($xml);
    echo dom_import_simplexml($parser)->textContent;
    

提交回复
热议问题