Read XML filewith HTML tags by using PHP -
i have xml file must import in wordpress. problem tags not compatible wordpress.
so first, load xml php :
$fichier = 'communiques.xml'; date_default_timezone_set('europe/paris'); $xml = simplexml_load_file($fichier);
and foreach, change tags.
my problem :
my "content" tags contain html tags. when print var, content html return lot of array.
[h3] => lorem ipsum .... [p] => array ( [0] => simplexmlelement object ( [b] => array ( [0] => lorem ipsum dolor [1] => sit amet, consectetur [2] => tennis et padel [3] => simplexmlelement object ( [br] => simplexmlelement object ( ) ) [4] => adipiscing elit. [5] => praesent id [6] => lorem ac quam malesuada : [8] => dapibus. nunc posuere commodo lorem ) [br] => array ( [0] => simplexmlelement object ( ) [1] => simplexmlelement object ( ) [...] [46] => simplexmlelement object ( ) [47] => simplexmlelement object ( ) ) [i] => « lorem ipsum dolor sit amet, consectetur adipiscing elit. praesent id lorem ac quam malesuada dapibus. nunc posuere commodo lorem sed pretium. aliquam malesuada placerat convallis. vivamus sed orci eu ipsum congue tincidunt semper in justo. nulla congue congue turpis @ luctus. » ) [1] => lorem ipsum dolor sit amet, consectetur adipiscing elit. praesent id lorem ac quam malesuada dapibus. ) [img] => array ( [0] => simplexmlelement object ( [@attributes] => array ( [src] => uploads/folder/text_name.jpg [alt] => ) ) [1] => simplexmlelement object ( [@attributes] => array ( [src] => uploads/folder/perspective_2.jpg [alt] => ) ) ) )
how can display content in tag (with html tags) :
<content:encoded><![cdata[ content here ]]></content:encoded>
the rest works !
problem solved. added
[cdata[...]]
and removed "encoded" xml file.
Comments
Post a Comment