Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML to HTML and back to XML

Status
Not open for further replies.

borgrulze

Programmer
Apr 4, 2002
11
0
0
IN
Hi,
i have a XML and a corresponding XSL file to convert it to HTML. Now is there any tool that will produce another XSL which would convert the HTML back to original XML.
Thank you
 
And just why would you need to do this? A class project, perhaps? Please explain if you have a legitimate reason, as any professional would know enough to SAVE THE INPUT!
 
i think you misunderstood. i shall rephrase it. Suppose i have a XML file and i write an XSL file to convert it to HTML. Now suppose i need to do the reverse process input would HTML and i would need to generate the XML. Now input HTML need not necesarily the same output from the previous conversion.
 
That's a tougher conversion, as HTML parsers are extremely lenient: they don't take the notion of "well-formed" as seriously as XML does.

So, it depends on how much your HTML pushes the bounds of what is legit and what will pass. You might be able to do the job with XSL if the HTML isn't too wild. Before I tried that, though, I'd Google for a tool that might already be out there. Do some research.
 
Yes that's exactly what i did before posting here. I could not find such a tool and i can't believe it does not exists.
 
Again, consider the difficulty of what you want. Here's a clue: how many viable Web browsers (HTML parsers) are there? What kind of resources do you think it takes to create such a beast?
 
Start with this:
Clean your HTML up with Tidy:

After that you have to write an XSLT-Stylesheet to transform your html into xml.
Or: You find a tool that can do that.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top