Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_php thread: Professional PHP


Message #1 by "Phil Perks" <philp@w...> on Tue, 8 Aug 2000 14:25:20
-----Original Message-----
From: Eduardo Almeida - Nexos [mailto:eduardo@n...]
Sent: 07 August 2000 19:45
To: support@w...
Subject: Professional PHP

Friends, i have this 3 simples files php,xml and xsl.

Programming with xml and xsl in browser is ok.

My problem is when get the php to open the file xml, process is to he the 
xml, get the file xsl and display in format definied.

But this not happen, he display asc normal, this write php,xml e xsl dont 
speek, help me.

In book, Professional PHP you not work with xsl, but i have.

This is code of files: 

php: 

<?php

function startElementHandler($parser,$name,$attribs){

echo("<$name><BR>");

} 

function endElementHandler($parser,$name){

echo("</$name><BR>");

} 

function cdataHandler($parser,$data){

echo("$data<BR>");

} 

$parser = xml_parser_create();

xml_set_element_handler($parser,"startElementHandler","endElementHandler");

xml_set_character_data_handler($parser,"cdataHandler");

$file = "tes.xml";

if(!($fp = fopen($file,"r"))){

die("nada");

}

while ($data = fread($fp,4096)){

if (!xml_parse($parser,$data,feof($fp))){

die(sprintf("XML %d 
%d",xml_get_current_line_number($parser),xml_get_current_column_number($parser)));

}

}

?> 

xml 

<?xml version="1.0" encoding="ISO-8859-1" ?>

<?xml-stylesheet type="text/xsl" href="tes.xsl"?>

<!--Colocar DTD-->

<listalivros>

<livro>

<title>Php</title>

<autores>

<autor>Eduardo Almeida</autor>

<autor>Josue Junior</autor>

</autores>

</livro> 

<livro>

<title>Unix</title>

<autores>

<autor>Gorgonio</autor>

</autores>

</livro>

</listalivros> 

xsl 

<?xml version="1.0" ?> 

- <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl"> 

- <xsl:template match="/"> 

- <html> 

- <head> 

<title>Pagina Xml gerada com xsl</title> 

</head> 

- <body> 

Nossos Livros sao: 

- <xsl:for-each select="listalivros"> 

<xsl:value-of select="." /> 

</xsl:for-each> 

</body> 

</html> 

</xsl:template> 

</xsl:stylesheet>



========================================

Eduardo Almeida

Salvador - Ba - Brazil





  Return to Index