note 82686 added to ref.simplexml

From: Date: Tue, 22 Apr 2008 00:28:05 +0000
Subject: note 82686 added to ref.simplexml
Groups: php.notes 
Request: Send a blank email to php-notes+get-138631@lists.php.net to get a copy of this message
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])); } ?> ---- Server IP: 209.41.74.194 Probable Submitter: 76.17.239.140 ---- Manual Page -- http://www.php.net/manual/en/ref.simplexml.php Edit -- https://master.php.net/note/edit/82686 Del: integrated -- https://master.php.net/note/delete/82686/integrated Del: useless -- https://master.php.net/note/delete/82686/useless Del: bad code -- https://master.php.net/note/delete/82686/bad+code Del: spam -- https://master.php.net/note/delete/82686/spam Del: non-english -- https://master.php.net/note/delete/82686/non-english Del: in docs -- https://master.php.net/note/delete/82686/in+docs Del: other reasons-- https://master.php.net/note/delete/82686 Reject -- https://master.php.net/note/reject/82686 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#138631) next »