How do I parse a XML file and create an equvalent HTML file and vice versa?

  • Thread starter Thread starter Hameem
  • Start date Start date
H

Hameem

Guest
I need to parse a XML file using java and create an equvalent HTML file and also need to parse a HTML file and generate an equvalent XML file.
Thank you. Code would be appriciated...or the ways to do it.
 
To make it an HTML file,try changing the file extension of the file to .html,or copy the whole code and paste it in another program that uses the same code and saves it as an HTML file.=)
 
To make it an HTML file,try changing the file extension of the file to .html,or copy the whole code and paste it in another program that uses the same code and saves it as an HTML file.=)
 
There is no such thing as an 'equivalent HTML file' for an XML file. HTML is a form of XML, any browser can display XML as a normal HTML page, there's nothing special you need to do.

If you want to display it as html simply point your browser to the XML file just as it is (or make a link to it or whatever) and it will be displayed, tag by tag, item by item.

If you need special formatting, then you can simply take the info from the XML and manually format it with CSS into a normal HTML.

Note: you shouldn't change the extension since then the browser will try to read the XML as HTML, but it won't recognize the tags so you'll simply get a dump of the text inside tags.
 
Back
Top