This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit ezplatform.com

eZ Community » Forums » Install & configuration » EZ XML
expandshrink

EZ XML

EZ XML

Wednesday 22 January 2003 10: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

No reply yet!

expandshrink

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

36 542 Users on board!

Forums menu

Proudly Developed with from