Created
January 13, 2016 16:04
-
-
Save perseoq/fda41ca39ad95167afdd to your computer and use it in GitHub Desktop.
Crear un archivo XML con CDATA con PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class SimpleXMLExtended extends SimpleXMLElement { | |
public function addCDATA($cData) { | |
$node = dom_import_simplexml($this); | |
$node->formatOutput = true; | |
$no = $node->ownerDocument; | |
$node->appendChild($no->createCDATASection($cData)); | |
} | |
} | |
$get_num = $_POST['numero']; | |
$get_tit = $_POST['titulos']; | |
$get_cap = $_POST['capitulos']; | |
$get_secc = $_POST['secciones']; | |
$get_atrib = $_POST['editor1']; | |
$dicc = new SimpleXMLExtended('datagrid.xml', null, true); | |
$nodo = $dicc->addChild('articulo'); | |
$path = $nodo->addChild('atributo'); | |
$path->addCDATA(html_entity_decode($get_atrib)); | |
$nodo->addChild('numero',$get_num); | |
$nodo->addChild('titulo',$get_tit); | |
$nodo->addChild('capitulo',$get_cap); | |
$nodo->addChild('seccion',$get_secc); | |
$dicc->asXML('datagrid.xml'); | |
header('location: index.php'); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment