j'ai commencé un programme en utilisant les fonctions DOMXML...
voici un bout de code
Php
function CreateDOMTextElement($DOMdocument,$parentNodeName,$newNodename,$couleur,$size,$text)
{
$node=$DOMdocument->get_elements_by_tagname($parentNodeName);
$newNode=$DOMdocument->create_element($newNodename);
$childnode=$DOMdocument->append_child($newNode);
$childnode->set_attribute("couleur",$couleur);
$childnode->set_attribute("size",$size);
$childnode=$DOMdocument->append_child($DOMdocument->create_text_node($text));
}
$dom=domxml_new_doc("1.0");
$firstchildName="document";
$firstchild = $dom->create_element($firstchildName);
$document = $dom->append_child($firstchild);
$document->set_attribute("pagewidth","210");
$document->set_attribute("pageheight","297");
$document->set_attribute("background","#FFFFFF");
CreateDOMTextElement($dom,$firstchildName,"nom","#CCCCCC","12",$_SESSION['CVnom']);
CreateDOMTextElement($dom,$firstchildName,"prenom","#CCCCCC","12",$_SESSION['CVprenom']);
CreateDOMTextElement($dom,$firstchildName,"titre","#CCCCCC","12",$_SESSION['CVtitre']);
CreateDOMTextElement($dom,$firstchildName,"adresse","#CCCCCC","16",$_SESSION['CVadresse']);
CreateDOMTextElement($dom,$firstchildName,"cp","#CCCCCC","8",$_SESSION['CVcp']);
CreateDOMTextElement($dom,$firstchildName,"ville","#CCCCCC","8",$_SESSION['CVville']);
CreateDOMTextElement($dom,$firstchildName,"telephone","#CCCCCC","8",$_SESSION['CVtelephone']);
CreateDOMTextElement($dom,$firstchildName,"fax","#CCCCCC","8",$_SESSION['CVfax']);
CreateDOMTextElement($dom,$firstchildName,"mobile","#CCCCCC","8",$_SESSION['CVmobile']);
CreateDOMTextElement($dom,$firstchildName,"email","#CCCCCC","8",$_SESSION['CVemail']);
CreateDOMTextElement($dom,$firstchildName,"url","#CCCCCC","16",$_SESSION['CVurl']);
//echo $dom->dump_mem(true, 'UTF-8' );
$dom->dump_file('essai.xml');
echo 'Export XML effectue !<br><a href="essai.xml">Voir le fichier</a>';
mon programme génère une page xml visiblement erronnée... pourquoi ?
http://www.clonecopy.net/php/ezdocs/essai.xml
quelqu'un connait l'extension DOMXML de PHP ?
j'arrive pas à imbriquer mes balises correctement... elles se forment toutes sous la forme :
Code
<balise1 attribut="123"/>
<balise2 attribut="123"/>
<balise2 attribut="123"/>
au lieu de :
Code
<balise1 attribut="123">
</balise1>
<balise2 attribut="123">
</balise2>
</balise1>
<balise2 attribut="123">
</balise2>
resultat... le DOM inspector de firefox les voit toutes imbriquées les unes dans les autres :
Code
document
|____balise1
|____balise2
|____balise1
|____balise2
au lieu de
Code
document
|___balise1
|___balise2
|___balise1
|___balise2
comment je peux faire ?