XML Parsing - Tag contents are split at apostrophes
Posted: Wed Aug 15, 2007 8:50 am
Hi,
I'm currently trying to write some code to parse an RSS news feed, using the standard XML Parser functions (the site I am working on must run on a PHP4 server, hence no SimpleXML, unfortunately).
I have got the parser and all its handlers essentially working. However, I have found that when the contents of a tag are passed to the character data handler, if there is an apostrophe then the contents will be split up, resulting in multiple calls to the handler. For example:
If I output the individual pieces of data passed to the character data handler for the above snippet of XML to an array, the result is:
This also appears to occur with other special characters, such as quotes (") or pound signs (£). I want the entire contents of the tag to be passed to the handler in one go, not piece-by-piece as above. I've tried searching on Google but I can't find any explanation for this behaviour. Could someone please help?
I'm currently trying to write some code to parse an RSS news feed, using the standard XML Parser functions (the site I am working on must run on a PHP4 server, hence no SimpleXML, unfortunately).
I have got the parser and all its handlers essentially working. However, I have found that when the contents of a tag are passed to the character data handler, if there is an apostrophe then the contents will be split up, resulting in multiple calls to the handler. For example:
Code: Select all
<title>House plans 'will hit green belt'</title>Code: Select all
[0] => House plans
[1] => '
[2] => will hit green belt
[3] => '