Archive | Code Snippets RSS for this section

PHP Code-Snippet: Replacing CDATA content of a SimpleXMLElement object

This little challenge took me too much time to not letting people know the solution I came up with. So when I am forced to work with PHP and want to process XML files, I prefer using PHP’s SimpleXML interface, because I found out that I need the least number of LOC for querying particular nodes within a document. It also provides methods for manipulating the DOM tree, but it appears that the possibilities are highly limited and in particular there is no method for creating CDATA sections. Here is the result of my Stackoverflow.com and try&error session.

Read More…