aspose file tools*
The moose likes Other Open Source Projects and the fly likes HTML to XML Conversion and Vice Versa Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "HTML to XML Conversion and Vice Versa" Watch "HTML to XML Conversion and Vice Versa" New topic
Author

HTML to XML Conversion and Vice Versa

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9524
    
    2

Guys,

Any opensource Java API that could be used for such a conversion?


SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9524
    
    2

I'd like to do something like wherein a user enters information on a HTML form, upon submit of that form, I have to represent the entire data as XML and later when the user wishes to see that HTML with data, the information is taken from the XML that I initially got. I also have to keep in mind the Roles and Rights when rendering the data. Any idea on any Java API's that could be used for this purpose?
Leandro Coutinho
Ranch Hand

Joined: Mar 04, 2009
Posts: 417
I never did this, but searching in Google I found JAXP and HTML Tidy.

JAXP: XML -> HTML
HTML Tidy: HTML -> XML

I don't know if the inverse is also true.

http://www.ibm.com/developerworks/xml/library/x-jaxp/
http://www.ibm.com/developerworks/library/x-tiptidy.html
Ram Para
Ranch Hand

Joined: Jul 09, 2008
Posts: 50
try XForms also.


Ram Parashar
http://doinfinite.com
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9524
    
    2

Did you mean JTidy? I've never heard HTML Tidy. I'm looking for an OpenSource API that I can use to extend for my purpose that I mentioned in the post above. Is the HTML Tidy a Java API?
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9524
    
    2

Ok, let me explain what I'm trying to achieve here. I have a HTML form upon logging into an application. Now I enter some details in the form and I submit the form. Now what I want to happen is the entire HTML form must be captured along with the style information and depicted as a XML. Now later when the user comes and (the user has the option to view the filled HTML form) requests for the filled HTML form, I give him the XML which needs to now be represented as the HTML page output.

I guess we could use XSLT?? Am I right in this sense?
Ram Para
Ranch Hand

Joined: Jul 09, 2008
Posts: 50
try this

http://www.w3schools.com/xforms/default.asp
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42641
    
  65
What do you mean by "style information"? HTML forms submit name/value pairs, nothing else.

How (and why) do you intend to store this information as XML, if later you need to output it as HTML?


Ping & DNS - my free Android networking tools app
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9524
    
    2

Ulf Dittmer wrote:What do you mean by "style information"? HTML forms submit name/value pairs, nothing else.

How (and why) do you intend to store this information as XML, if later you need to output it as HTML?


I means the CSS styles. Yes, is the answer to your second question. Later I want to retrieve the output as HTML.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42641
    
  65
Jothi Shankar Kumar wrote:
Ulf Dittmer wrote:What do you mean by "style information"? HTML forms submit name/value pairs, nothing else.

How (and why) do you intend to store this information as XML, if later you need to output it as HTML?


I means the CSS styles.

CSS styles are not submitted to the server - they are *generated* by the server and sent to the client. What exactly are you trying to do? Where is this style information coming from? What do you intend to do with it?

Yes, is the answer to your second question.

The question starts with "How (and why)..." - a "Yes" does not answer it.
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9524
    
    2

I have a HTML form where the user enters some information in the HTML and later he decides to save that page or submit that page. Now when he does that I want to capture the entire page with data as an XML. Have a mapping kind of indormation and hit the database to save the XML id along with some other information. Later when the user tries to view the same page, I hit the database, get the correct XML id and look for that XML which will now be represented to the user on the screen as HTML.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42641
    
  65
OK, so there's really no style information to save at all. You already know all the styles used by the original form (after all, your web app generated it), so all you need to do is to style the web page showing the reconstituted data later on using the same styles.

So the question then boils down to - how to convert HTML form name/value pairs as XML, store it, retrieve it later, and then convert it back to HTML. That begs the question: why do you want to use XML? Why can't the name/value pairs be stored in a non-structured way in the DB (or as a property file, if your prefer that)?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HTML to XML Conversion and Vice Versa