Click to See Complete Forum and Search --> : selected XML to XHTML


supersteve3d
10-10-2006, 06:23 AM
Hi all,

I asked in the php forum with no news as of yet. Since I am not too sure of the scope of php vs javascript. I wonder if this is possible to do in js.

I wish to read xml or txt files in and convert them (styled , tabulated) into html.

Is there an easy way to do this? I assume using xml is better than trying to read in text.

I do not want to simply cut and paste the whole file but rather look for certain tags to place and style them differently. As such I assume XML is a better choice?

Thanks.

ray326
10-10-2006, 12:58 PM
Depending on the complexity of the content XML is probably the better choice. If it's simple tabular data then comma or tab separated text would be easier. At any rate, the conversion should be done on the server so look at something like PHP rather than JS.

Charles
10-10-2006, 02:22 PM
XML Stylesheet Language Transformations (XSLT) is the way to go. You can use PHP to run the stylesheet or let the browser. But don't try the second if you use external entities.

supersteve3d
10-10-2006, 08:01 PM
Thanks for your replies. I have only just found out about XSLT. It seems to do exactly what I want. However, it seems a little complex. Also, the final file seems to be .xml even though its XHTML syntax within.. is this correct?

I ask because I intend to do a php include of the resulting file, to fit it into my site's template.

Charles
10-10-2006, 08:17 PM
XSLT can output to any text based format, HTML, XHTML, RTF, even PDF.

See http://saxon.sourceforge.net/saxon6.5.5/xsl-elements.html#xsl:output .