Page 1 of 1

DOM vs XSLT

Posted: Sat Jun 28, 2008 10:42 am
by jamesm6162
I want to insert some formatted XML data into my webpage using php.

My question is which option would be the best choice in terms of performance:

1.) Using the php DOM functions and iterating over the structure mannually

2.) Or using the XSLTProcessor class and simply creating an XSLT stylesheet to use with it. (3 lines of php code)

Note: I do not need to write to the data, only read from it.

Re: DOM vs XSLT

Posted: Sat Jun 28, 2008 11:40 am
by jayshields
DOM is a way of creating a model of a whole XML document in memory. XSLT is a transformation language for XML. They accomplish different tasks.

Just use XSLT, you don't need to use PHP.

Re: DOM vs XSLT

Posted: Sat Jun 28, 2008 2:02 pm
by jamesm6162
Thanks for the reply.

I know exactly what each one does, and you CAN use both for the task I have in mind.

I need to insert the data on the fly, as part of an entire web application written in php. So I have to use PHP.

I am simply wondering which would perform faster/better on the server (Not which is better for convenience):
Using the XSLTProcessor class or using the PHP DOM functions (DOMDocument, DOMNode etc.) to traverse the tree and manipulate as needed.