Re: [Htmlparser-user] Adding elements to the html
Brought to you by:
derrickoswald
From: Joel <jo...@ha...> - 2007-01-11 14:23:26
|
I just didn't realize the need of end tag. That works. Thanks, Joel Martin Sturm wrote: > Hi, > > I did a quick test, and I think you forgot to add the endtag to the > toCreate object. > You should add: > > toCreate.setEndTag(new Span()); > > before you final println statement. > > The following code snippet works for me: > TagNode toCreate = new Span(); > toCreate.setAttribute("key", "Test", '"'); > NodeList nl = new NodeList(); > nl.add(new TextNode("Test2")); > toCreate.setChildren(nl); > toCreate.setEndTag(new Span()); > System.out.println(toCreate.toHtml()); > > Result: <SPAN key="Test">Test2<SPAN> > > Hope this will help you. > > -- Martin > > > 2007/1/10, Joel <jo...@ha... <mailto:jo...@ha...>>: > > I want to wrap text string with a span tag. I've tried the > folowing, but > I'm running into a problem, that the tag's children aren't being > displayed. > > //New <span key="x">some text here</span> > TagNode toCreate = new Span(); > toCreate.setAttribute("key", getKey(str), '"'); > NodeList nl = new NodeList(); > nl.add(new TextNode(str)); > toCreate.setChildren (nl); > System.out.println(toCreate.toHtml()); > > This ends up showing <span key="x"> without the text node and end tag, > what am I doing wrong? > > Joel > > > > > ------------------------------------------------------------------------- > > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to > share your > opinions on IT & business topics through brief surveys - and earn > cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > <http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV> > _______________________________________________ > Htmlparser-user mailing list > Htm...@li... > <mailto:Htm...@li...> > https://lists.sourceforge.net/lists/listinfo/htmlparser-user > <https://lists.sourceforge.net/lists/listinfo/htmlparser-user> > > > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys - and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > ------------------------------------------------------------------------ > > _______________________________________________ > Htmlparser-user mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/htmlparser-user > |