Skip to content

Instantly share code, notes, and snippets.

@harmstyler
Created October 18, 2012 14:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harmstyler/3912306 to your computer and use it in GitHub Desktop.
Save harmstyler/3912306 to your computer and use it in GitHub Desktop.
Handle xml fields in eZ Publish
function handleXmlField($bodyXml, $parser="simple")
{
$parser = new eZSimplifiedXMLInputParser(null);
if ($parser == 'oe') {
$parser = new eZOEInputParser(null);
}
$parser->setParseLineBreaks(false);
$document = $parser->process($bodyXml);
if (!is_object($document)) {
$document = $parser->createRootNode();
}
$result = eZXMLTextType::domString($document);
$result = str_replace('<section xmlns:image="http://ez.no/namespaces/ezpublish3/image/" xmlns:xhtml="http://ez.no/namespaces/ezpublish3/xhtml/" xmlns:custom="http://ez.no/namespaces/ezpublish3/custom/"/>', '', $result);
return $result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment