• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Which is the efficient way to convert XML to HTML?.

 
Ranch Hand
Posts: 652
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ranchers,
I wanted to know which is the efficient way to convert XML to HTML?.I have downloaded a tool which does this and also i was going through the XSLT tutorial.Please let me know which is the best way to do it.


Regards,
Nik
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Efficient in which way - fast to program, fast to execute, least amount of code involved, ... ?

There generally is no single "best way", as it depends very much on your circumstances (about which we know nothing) which one that may be. XSLT would be be one way; use of XML APIs and direct generation of HTML markup another one.
 
Nik Arora
Ranch Hand
Posts: 652
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ulf,
Thanks for your reply. I wanted a information regarding conversion of XML to HTML and XML to PHP.I have not worked with PHP but want to know which is more useful whether converting XML to HTML or XML to PHP and the efficiency in executing.


Regards,
Nik
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HTML is a markup language for display, while PHP is a programming language for generating (mostly) HTML, so I'm not sure how converting XML into either of them can be compared. What does it mean to convert XML to PHP?
 
Nik Arora
Ranch Hand
Posts: 652
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ulf,

Originally posted by Ulf Dittmer:
What does it mean to convert XML to PHP?



It means that converting an xml file into a php file but is it possible because php uses certain php tags to do it.I dont have an idea.Please let me know on this idea.

Regards,
Nik
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

It means that converting an xml file into a php file but is it possible because php uses certain php tags to do it.


Now you seem to be talking about two different things: converting an XML file into a PHP file, and using PHP to convert XML into HTML. If it's the former, please elaborate what that means. If it's the latter, you might be better off posting this in a PHP forum.
 
Nik Arora
Ranch Hand
Posts: 652
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ulf,
It's the latter that is converting an XML file into a PHP file.Any suggestions on how to do this ulf?.


Regards,
Nik
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, because I don't know what it means to convert an XML file into a PHP file.
 
Nik Arora
Ranch Hand
Posts: 652
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ulf,
Sorry for all the confusions.I will explain you what i need exactly.Please suggest me.I have lots of xml file. Now i want the data in xml file to be displayed in a well defined table structure and it should be a web page.

I got few suggestions from my friends i have mentioned them below.

1.Convert the XML file to HTML and display it.

2.Use PHP.

So i was confused how to carry it forward.Please let me know on how to carry it forward i am really confused regarding which is the best way to do it.


Regards,
Nik
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To quote my first post

There generally is no single "best way", as it depends very much on your circumstances (about which we know nothing) which one that may be.

XSLT would be be one way; use of XML APIs and direct generation of HTML markup another one.


If you're familiar with the Java XML APIs, that might be easier to start with. Using XSLT might be a cleaner approach that separates the transformation logic (and thus the markup) from the code doing the transformation.

I'm not too familiar with PHP, but I would imagine that it is possible to implement these two approaches using just about any language, including PHP.
 
Nik Arora
Ranch Hand
Posts: 652
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ulf,
I did not understand these

use of XML APIs and direct generation of HTML markup another one.

Please explain me.


Regards,
Nik
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can use the Java API for XML processing -JAXP, and in particular its SAX API- to read the XML, and then write the HTML directly to a file using the java.io package. The http://faq.javaranch.com/java/XmlFaq links to some introductory material on this, e.g. the article titled "Introduction to DOM and SAX Parsing".
 
Nik Arora
Ranch Hand
Posts: 652
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ulf,
Thanks for the reply.Which will be better using XSLT or using java and SAX api?.Which will be more efficient in terms of execution?.And what are the advantages using XSLT or Java comparing to each other.

Regards,
Nik
[ January 22, 2008: Message edited by: Nik Arora ]
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The question of which is better can't be answered in general. It much depends on the circumstances of the application, the software ecosystem it runs in, the developers' knowledge, etc. - all of which we know nothing about.

What do you mean by "efficient" - faster? If so, probably SAX, since there is a certain overhead in using XSLT. But XSLT has other benefits (like separating the logic from the markup being used) that may be more important.

But is raw performance really that important? If it is, you should definitely implement both, and then do speed tests in an environment that's comparable to the production system, using realistic data sets. But in my experience, raw performance numbers are rarely the deciding factor in design issues like this.
 
Nik Arora
Ranch Hand
Posts: 652
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot ulf.



Regards,
Nik
 
reply
    Bookmark Topic Watch Topic
  • New Topic