Page 1 sur 1

probleme mise en forme xml en html

Posté : 08 févr. 2011, 10:22
par dvarz
bonjour j'ai un fichier xml et je voudrais que quand il y a un certain type de balise cela soit traduit par un </br> mais je n'arrive pas à le faire. voici un extrait de mon fichier xm.
<actu>
<article idArticle="lea111091" rubrique="ado" dateArticle="02/02/2011">
<copyright>Copyright Bidon</copyright>
<titrearticle>Le titre</titrearticle>
<chapitre>
<titrechapitre>la vie etudiante</titrechapitre>
<refchapitre>article 95</refchapitre>
<photo src="http://ado.jpg"/>
<contenu>
<paragraphe>
                    <texteparagraphe>blablabla<retourligne/>
                        <retourligne/>lalalalalalalalalala</texteparagraphe>
                    <texteparagraphe>
                        <annotation>
                            <titreannotation>Nouveauté :</titreannotation>
                            <texteannotation>merci à toto<exposant>er</exposant>blabla</texteannotation>
                        </annotation>
                    </texteparagraphe>
                </paragraphe>
</contenu>
</chapitre>
</article>
</actu>

Je voudrais donc que lorsqu'il y a une balise <retourligne/> cela soit traduit par un </br> avec un test de type si <retourligne/> détecté alors echo </br> si possible bien sure . je fait cela en php simple xml. Merci de votre aide ;)

Re: probleme mise en forme xml en html

Posté : 08 févr. 2011, 10:25
par xTG
Est-ce qu'un str_replace() ferrait l'affaire ?

Re: probleme mise en forme xml en html

Posté : 08 févr. 2011, 10:30
par dvarz
c'est possible mais je pense qu'il y a plus simple avec l’utilisation de fonctions simple xml non ?

Re: probleme mise en forme xml en html

Posté : 08 févr. 2011, 11:11
par dvarz
foreach ($value->chapitre->contenu->paragraphe->texteparagraphe as $chapitre) {
$retour_ligne=$chapitre->retourligne->getName();
$retour_ligne= str_replace("retourligne" ,"</br>",$retour_ligne);
echo $retour_ligne;
echo "<pre>".$chapitre."</pre>";
}


cela fonctionne mais n'affiche pas le </br> de manière synchroniser avec les textparagraphe.

Re: probleme mise en forme xml en html

Posté : 08 févr. 2011, 11:28
par stealth35
c'est pas </br> c'est <br/> :wink:

Re: probleme mise en forme xml en html

Posté : 08 févr. 2011, 11:29
par dvarz
oups merci pas fait gaf kel pitre je suis ^^