aspose file tools*
The moose likes Other Open Source Projects and the fly likes Can we create HTML tags using JAVA API ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Can we create HTML tags using JAVA API ?" Watch "Can we create HTML tags using JAVA API ?" New topic
Author

Can we create HTML tags using JAVA API ?

Mohammed Yousuff
Ranch Hand

Joined: Oct 17, 2007
Posts: 198
Is there any API in java which will create HTML tags for me ?

i came accrros some of the HTML parser which will parse the HTML tags. but not sure about the HTML creation.

please let me know if you have any thoughts on this


My Thoughts : http://passion4java.blogspot.com
Try not to become a man of success but rather to become a man of value.
Adam Asham
Greenhorn

Joined: Jul 06, 2006
Posts: 13
One option could be to utilize the XML DOM package and serialize the created XML nodes. Of course you get no way to detect whether the document is well-formed or not...
[ October 24, 2008: Message edited by: Adam Asham ]
Adam Asham
Greenhorn

Joined: Jul 06, 2006
Posts: 13
Hmm, I think javax.swing.text.html is a much better alternative.
I don't know why they put html in there. It's not the most logic location for handling HTML documents...
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61762
    
  67

There used to be a Jakarta project called ECS (Element Construction Set), but I think it's been long-abandoned.

Of course, if this is in the context of a web app, writing the HTML directly in a JSP is the accepted best practice.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Dan Howard
Ranch Hand

Joined: Feb 22, 2004
Posts: 47
See my thread on Jolene. The document objects that Jolene creates when parsing an HTML file can also be used on their own.

example:

Image img = new Image();
img.setAttribute("src", "/img/smile.png");
img.setAttribute("alt", "Smile");
img.setAfterText("Click me!");
button.setContent(img);
button.setValue("Click");

Which would output (using toString):

<button name="MyButton" value="Click"><img alt="Smile" src="/img/smile.png">Click me!</button>


http://jolene.sourceforge.net/
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

As an Aside I moved the Jolene thread to the Blatant Advertising forum as per the Javaranch policy, so for those who are interested please check there .


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
Dan Howard
Ranch Hand

Joined: Feb 22, 2004
Posts: 47
This is a small open source project of mine. It's LGPL and I'm not asking for money.

I've been using this approach for building web applications for several years and about 6 months ago I decided to hunker down and put it all together for release. It's a 1% inspiration 99% perspiration thing. It took a lot of work to get it out there and I would like it if some developers would kick the tires a bit.

This is a great forum with a lot of users who I think could benefit from this approach. If you that crass advertising then sorry.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can we create HTML tags using JAVA API ?