note 82686 deleted from function.simplexml-load-string by cmb

From: Date: Sun, 15 Dec 2019 10:15:15 +0000
Subject: note 82686 deleted from function.simplexml-load-string by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-213535@lists.php.net to get a copy of this message
Note Submitter: kyle at codeincarnate dot com ---- A looked through a lot of the sample code for reading XML files with CDATA, but they didn't work out that well for me. However, I found that the following piece of code worked perfectly for reading through a file using lots of CDATA. <?php $article_string = file_get_contents($path); $article_string = preg_replace_callback('/<!\[CDATA\[(.*)\]\]>/', 'filter_xml', $article_string); $article_xml = simplexml_load_string($article_string); function filter_xml($matches) { return trim(htmlspecialchars($matches[1])); } ?>

« previous php.notes (#213535) next »