Share » Forums » Developer » How to render an XML Block into XHTML...

How to render an XML Block into XHTML (PHP script)

How to render an XML Block into XHTML (PHP script)

Wednesday 27 May 2009 11:58:38 pm - 4 replies

Author Message

Damien Pobel

Wednesday 03 June 2009 3:20:52 am

Hi Hakim,

To get the XHTML output of an XML Block attribute, you can write something like :

$dataMap = $node->attribute( 'data_map' );
$output = $dataMap['your_attribute_identifier']->attribute( 'content' )->attribute( 'output' );
$xhtml = $ouput->attribute( 'output_text' );

And to convert the XHTML to plain text, you can use the strip_tags PHP function [1]

[1] http://php.net/strip_tags

Damien
Planet eZ Publish.fr : http://www.planet-ezpublish.fr
Certification : http://auth.ez.no/certification/verify/372448
Publications about eZ Publish : http://pwet.fr/tags/keywords/weblog/ez_publish

Hakim Bouras

Thursday 04 June 2009 4:38:24 am

Hi Damien,

Thanks a lot for your help.

Actually I had to change a small thing to make it work : to use the method "outputText()" instead of the attribute "output" (but this is maybe due to the fact I am using a version 4.1).

$output = $dataMap['your_attribute_identifier']->attribute( 'content')->attribute( 'output' );
$xhtml = $output->outputText();

Cheers,
Hakim

André R.

Thursday 04 June 2009 6:02:24 am

Hakim: what class is $output? ( call "var_dump($output);" for instance)

$ouput->attribute( 'output_text' ); should have worked, as it uses outputText() in eZXMLOutputHandler, but if you have another output handler for some reason, then it might not work.

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Hakim Bouras

Friday 05 June 2009 4:50:45 am

I retried the code provided by Damien, and in fact it is working fine. I probably missed something the first time I tried.

Thanks again for your help, and sorry for the burden,
Hakim

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu