homepage Welcome to WebmasterWorld Guest from 54.198.140.182
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / XML Development
Forum Library, Charter, Moderators: httpwebwitch

XML Development Forum

    
convert XML to HTML
heggenh




msg:3481698
 8:29 am on Oct 19, 2007 (gmt 0)

I need to convert a receiving XML into HTML, and save it as html.
This has to be done as the application where it later shall be used does not support xml format (only html, tiff and pdf).
So with the xsl I need to run through a directory, and convert all xml into html.
Is there a freeware out there that handles this?
Or does anyone have a good tip?

 

Marshall




msg:3481706
 8:49 am on Oct 19, 2007 (gmt 0)

Hi heggenh and welcome to WebmasterWorld.

The W3 Schools Tutorial [w3schools.com] should provide you with all the information you need.

Marshall

heggenh




msg:3481722
 9:27 am on Oct 19, 2007 (gmt 0)

I cannot see an answer on the w3.
I have read this site earlier, and the info there is more general and does not cover what I am looking for.
If I have overlooked the answer I would be happy for it to be pointed out.

I have no problem of presenting the data, but I cannot find a way to store it as an html. I need what I see in the browser to be stored as html.

Thanks for all help

Marshall




msg:3481725
 9:47 am on Oct 19, 2007 (gmt 0)

If I am understanding you correctly, you want to save the final output as viewed in your browser. If that is the case, the easiest method would be open the page in question, view the source code, then save the source code to a new HTML document.

Marshall

heggenh




msg:3481738
 10:16 am on Oct 19, 2007 (gmt 0)

Yes, that could be a sollution.
But when it is a batch of 1000 files, that will take too long.
So I need to make a script that can do this.
And that is where my problems start.
Does anyone know of something like this made before?

cmarshall




msg:3481748
 10:35 am on Oct 19, 2007 (gmt 0)

Welcome to WebmasterWorld!

You can use XSLT [w3schools.com] and PHP5 [us.php.net]. If you understand how to write XSLT [w3.org], then it is actually not difficult.

I am not aware of any pre-written XSLT [w3.org] scripts to do this, as your XML is probably custom XML.

I use XSLT [w3.org] to transform custom XML into XHTML [w3.org] and WML [w3schools.com].

If you are interested, and know how to use SourceForge Subversion [sourceforge.net], I can direct you to a project that has several XSLT [w3.org] scripts, used to transform custom XML into XHTML [w3.org], JSON [openmobilealliance.org] and WML [openmobilealliance.org] (WML 1.1 [openmobilealliance.org] and XHTML-MP 1.0 [lingvo.org]).

cmarshall




msg:3481930
 1:57 pm on Oct 19, 2007 (gmt 0)

Oops. That should have been JSON [json.org]

heggenh




msg:3481938
 2:03 pm on Oct 19, 2007 (gmt 0)

I have an XSL that I am using to present XML in a browser, and we have custom written it for the XML.
The problem is that the application later cannot use that XSL.
So I just want to use this XSL in order to get an HTML.
Can I build my xslt on the xsl I have?
Another guy said it should be doable justs by using the xsl.

cmarshall




msg:3482055
 3:51 pm on Oct 19, 2007 (gmt 0)

I have an XSL that I am using to present XML in a browser, and we have custom written it for the XML.
The problem is that the application later cannot use that XSL.
So I just want to use this XSL in order to get an HTML.
Can I build my xslt on the xsl I have?
Another guy said it should be doable justs by using the xsl.

It should be fine. I guess that you are sending the XSL to the browser, and the browser is doing the transform.

You can do the same thing on the server, as long as you have an XSLT processor that can run the stylesheet.

I use the PHP 5 XSLT Processor [us.php.net], which works great, as long as you keep your XSL to XSLT 1.0 [w3.org].

httpwebwitch




msg:3487245
 1:31 pm on Oct 25, 2007 (gmt 0)

I don't know of a batch XSLT processor that will do what you need, though I'll admit it would be a handy tool to own.

Sadly I'd suggest writing your own from scratch... the programming wouldn't be too difficult -

iterate through a folder's contents
read the file
transform XML>XSLT>HTML and save as...
loop

You could build it as a server application in PHP/ASP though it may be more portable to build it as a Windows app, ie. with Visual Studio / C#

httpwebwitch




msg:3487773
 9:00 pm on Oct 25, 2007 (gmt 0)

oh hey if these files are already on a web server, you can write a mini PHP script that transforms them on demand...

i.e. when someone asks for 12345.htm, you grab 12345.xml and transform it then output the result. one script, which handles all requests with a little rewrite rule in the .htaccess

RewriteRule (.*).htm transform.php?id=$1

then in the php...

$filename = $_GET['id'];
// load the file
// transform it
// print() the output

that's a paltry example in pseudocode, but that's the general idea

I've employed that technique to offer the same data in multiple formats, eg. "mydata.xml", "mydata.json", "mydata.html", "mydata.csv", "mydata.txt" etc - all handled by the same script, with multiple XSLT options

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / XML Development
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved