Skip to content

Instantly share code, notes, and snippets.

@brasofilo brasofilo/convert-xml.php
Last active Sep 2, 2018

What would you like to do?
Convert Codex XML to Apple Dictionary XML
header('Content-type: text/xml');
header('Pragma: public');
header('Cache-control: private');
header('Expires: -1');
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n";
echo '<d:dictionary xmlns="" xmlns:d="">' . "\r\n";
$codex = simplexml_load_file('codex.xml');
$count = 0;
foreach( $codex->page as $page )
$title = str_replace( 'Function Reference/', '', $page->title );
$id = str_replace( ' ', '_', $title );
# Avoid adding translated resources
if( false !== strpos( $title,':' ) )
<d:entry id="%1$s" d:title="%2$s">
<d:index d:value="%2$s"/>
htmlentities( $page->revision->text )
echo "\r\n";
echo '</d:dictionary>';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.