I've been trying to code some XML transformation using the XML_Transformer.
The objective was to convert the CDATA on the <data_po> and <prazo_data> tag to the corresponding dates.
But when i execute the code i only get the result from the end_XPTO methods, the return from the start_XPTO methods is just ignored....
Can anyone help me?
Thanks
My XML:
<LISTAGEM url="http://myserver/mypage/" apagar="true" editar="true" ver="true" cellpadding="0" cellspacing="1" border="0" width="100%" class="table">
<TITULO>
<LINHAHEADER style="padding-top: 7px;" align="center" valign="middle" class="smalltitle">
<a ROWSPAN="2">ID</a>
<b ROWSPAN="2">Nº</b>
<c ROWSPAN="2">Designação</c>
<d ROWSPAN="2">Nº peças</d>
<e WIDTH="40">Nº cliente</e>
<f ROWSPAN="2">Data PO</f>
<g COLSPAN="2">Prazos</g>
<h>Subcont.</h>
<i ROWSPAN="2">Cliente</i>
<j ROWSPAN="2">Pessoa</j>
</LINHAHEADER>
<LINHAHEADER style="padding-top: 7px;" align="center" valign="middle" class="smalltitle">
<a WIDTH="40">cliente</a>
<b>Dia</b>
<c>Semana</c>
<d>Empresa</d>
</LINHAHEADER>
</TITULO>
<CORPO>
<LINHA align="center" class="xlittletitle" BGCOLOR="#A7B0DA">
<id>1</id>
<num>1234</num>
<designacao>name1</designacao>
<num_pieces>1</num_pieces>
<num_cliente>722</num_cliente>
<data_po WIDTH="40">994978800</data_po>
<prazo_data WIDTH="40">1004486400</prazo_data>
<prazo_semana_ano>44/01</prazo_semana_ano>
<supplier>company3</supplier>
<client>Company4</client>
<person>some name</person>
</LINHA>
<LINHA align="center" class="xlittletitle" BGCOLOR="#C5C5C5">
<id>2</id>
<num>4321</num>
<designacao>name2</designacao>
<num_pieces>2</num_pieces>
<num_client>733</num_client>
<data_po WIDTH="40">994978800</data_po>
<prazo_data WIDTH="40">1004486400</prazo_data>
<prazo_semana_ano>44/01</prazo_semana_ano>
<supplier>company3</supplier>
<client>Company4</client>
<person>some name</person>
</LINHA>
</CORPO>
</LISTAGEM>
My XML_Transformer Namespace Class:
<?php
require_once "XML/Transformer.php";
require_once "XML/Util.php";
require_once "XML/Transformer/Namespace.php";
class datas extends XML_Transformer_Namespace {
function start_data_po($attributes){
$ret = "<data_po ".XML_Transformer_Util::attributesToString($attributes).">";
return $ret;
}
function end_data_po($cdata){
$ret = date("d-m-Y", $cdata)."</data_po>";
return $ret;
}
function start_prazo_data($attributes){
$ret = "<prazo_data ".XML_Transformer_Util::attributesToString($attributes).">";
return $ret;
}
function end_prazo_data($cdata){
$ret = date("d-m-Y", $cdata)."</prazo_data>";
return $ret;
}
}
?>