I’m trying to parse some XML using simpleXML in PHP.
The problem I’m having though, is that some nodes have values like Milk & Cheese and I’m getting a parse error.
What’s the easiest way of parsing XML using simpleXML with chars such as & and / being present?
Thanks
EDIT:
I’m using:
$source = 'stockdata.xml';
$stock = simplexml_load_file($source);
foreach($stock->StockItem as $item)
{
........
}
quick solution:
a better solution: [ if you control the xml ]
add CDATA in the xml tags
and you’ll need to tell SimpleXml to take care of the CDATA:
Hope this helps