Skip to content

Instantly share code, notes, and snippets.

@jakemcgraw
Created October 13, 2010 18:28
Show Gist options
  • Save jakemcgraw/624590 to your computer and use it in GitHub Desktop.
Save jakemcgraw/624590 to your computer and use it in GitHub Desktop.
<?php
$xml = <<<EOD
<?xml version="1.0" encoding="UTF-8"?>
<cmrl xmlns:dotgo="http://dotgo.com/cmrl/1.0" account="jddbb-ztc2l-f1tb7-2c8st">
<match pattern="">
<message><content>DOTGO.COM<br />
Welcome to DOTGO!<br />
<br />
Reply:<br />
<a query="dotgo about" /> What is DOTGO?<br />
<a query="dotgo blog" /> The DOTGO blog<br />
<a query="dotgo publishing" /> Publishing with DOTGO<br />
<a query="dotgo contact" /> Contact us<br />
<br />
Ex:<br />
3
</content></message>
</match>
</cmrl>
EOD;
$doc = new DOMDocument();
$doc->loadXML($xml);
$matches = $doc->getElementsByTagName("match");
$match = $matches->item(0);
$f = $doc->createDocumentFragment();
$arg = $_POST['content'];
$arg = str_replace(array('<![CDATA[', ']]>'), '', $arg);
$arg = '<content>'.stripslashes($arg).'</content>';
$f->appendXML($arg);
$match->replaceChild($f, $match->firstChild);
echo $doc->saveXML();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment