Re: [Htmlparser-user] Adding elements to the html
Brought to you by:
derrickoswald
|
From: Chen, Shui-S. <qoo...@gm...> - 2007-03-22 15:49:01
|
Hello everyone:
I have the same problem that i want to create an new node,and attach it to
an exist node.
The following are my code:
TagNode div=new Div();
div.setAttribute("style","xxxx");
NodeList tmp =new NodeList();
tmp.add(div);
div.setEndTag(new Div()); // is it a right
way to create end tag?
div.setChildren(traverseNode.getChildren());
((TagNode) traverseNode).setChildren(tmp); // the traverseNode is the
parent node(<li>) i want to attach on it
Finally i get the result:
<li><DIV style="xxx"><DIV></li>
instead of :
<li><DIV style="xxx"></DIV></li>
How can i create a correct end tag say : </DIV> ?
Stone
2007/1/11, Joel <jo...@ha...>:
>
>
> 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
> >
>
>
>
> -------------------------------------------------------------------------
> 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
>
|