Re: Parsing XML

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Peter Ford wrote:

> Per Jessen wrote:
>> 
>> That's cool, but XSL is still the more appropriate tool IMO.  It does
>> exactly what you need - it parses and validates the XML document,
>> allows you to extract the bits you need and in virtually any format
>> you need - which could be a text document with SQL statements for
>> piping to mysql.
>> 
>> 
>> /Per Jessen, Zürich
>> 
> 
> I'm with you on this, Per.
> You could even use the XSL to construct a bunch of PHP which could be
> eval'd or just read in as an include.
> Or better yet, if you use the XSL classes, you can register PHP
> functions and then call them within your XSL directly. That could
> potentially handle the validation you required, and even do the
> database inserts.

Yep, that occured to me too. I think XSL can even do quite a bit of the
validation too.

> I'm looking into using something like that on a project I'm currently
> working on: maybe I can come up with some examples in a couple of
> days...

Here's one easy example -

we generate monthly reports for our customers based on the activities of
the most recent month.  The template is an OpenOffice document (well,
several in different languages), which is merged with the activity data
to produce the report in OOo format.  The data is extracted and
formatted as XML. 
The process looks roughly like this:

OOo:template + XML:data -> apply XSL -> OOo document.  (We then turn the
final OOo document into a PDF which is emailed).  

Of course the same could be achieved using PHP, but instead of a neat
XSL stylesheet, I would have a pile of custom PHP code.

IMO, when you have a need to parse XML or otherwise extract data from
XML, you need a really good reason to disregard XSL.  The only really
good reason I've heard so far was lack of XSL skills, which could be a
real issue.  The learning curve IS quite steep. 


/Per Jessen, Zürich


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux