EZ XML

Author Message

Mike Cohen

Wednesday 22 January 2003 1:08:48 pm

Does anyone know how to use eZ XML to load information from an XML file into an eZ Publish template? The SDK examples show the use of eZ XML in a php file, but I don't think php will work in a .tpl file. I tried to use the SDK example in template, but it doesn't seem to work. Here's what I put in a class edit template, both with and without the {literal} tags.

{literal}
<?php
include_once( "/lib/ezxml/classes/ezxml.php" );

$xml = new eZXML();
$testDoc = "<?xml version='1.0'?>
<doc>
<article>
<paragraph name='Introduction'>Paragraph contents</paragraph>
<paragraph name='Story'>Story paragraph contents</paragraph>
</article>
</doc>";

$dom =& $xml->domTree( $testDoc );

print( "<b>XML document to parse:</b><br>" );

print( nl2br( htmlspecialchars( $testDoc ) ) );

print( "<br><b>Results from parsing:</b><br>" );
$paragraphs =& $dom->elementsByName( "paragraph" );

foreach ( $paragraphs as $paragraph )
{
// get the name of the item, should be paragraph
print( "<br/>New " . $paragraph->name() . ":<br/>" );

// print the value of the name attribute
print( "Name: " . $paragraph->attributeValue( "name" ) . "<br/>" );
print( "Content: " . $paragraph->textContent() . "<br/>" );
}

?>
{/literal}

Thanks for any help,

Mike

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 05:14:52
Script start
Timing: Jan 18 2025 05:14:52
Module start 'layout'
Timing: Jan 18 2025 05:14:52
Module start 'content'
Timing: Jan 18 2025 05:14:53
Module end 'content'
Timing: Jan 18 2025 05:14:53
Script end

Main resources:

Total runtime0.7056 sec
Peak memory usage4,096.0000 KB
Database Queries46

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0050 588.9219152.6094
Module start 'layout' 0.00500.0030 741.531339.4297
Module start 'content' 0.00800.6961 780.9609413.2266
Module end 'content' 0.70400.0015 1,194.18758.2031
Script end 0.7055  1,202.3906 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00320.4473160.0002
Check MTime0.00130.1867160.0001
Mysql Total
Database connection0.00080.111210.0008
Mysqli_queries0.666094.3917460.0145
Looping result0.00040.0593440.0000
Template Total0.677096.020.3385
Template load0.00190.267320.0009
Template processing0.675195.684320.3376
Template load and register function0.00030.035610.0003
states
state_id_array0.00080.108410.0008
state_identifier_array0.00110.159320.0006
Override
Cache load0.00160.2244320.0000
Sytem overhead
Fetch class attribute can translate value0.00060.088210.0006
Fetch class attribute name0.00070.092610.0007
XML
Image XML parsing0.00010.015610.0001
class_abstraction
Instantiating content class attribute0.00000.000710.0000
General
dbfile0.00060.0813100.0001
String conversion0.00000.001340.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
1content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
7content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
6content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 16
 Number of unique templates used: 5

Time used to render debug report: 0.0001 secs