Menu

how to get the text from "<font>"

Help
lilac
2005-04-02
2013-04-27
  • lilac

    lilac - 2005-04-02

    i want to get the text from the folleing text:<body>
      <ul>
      <li><font face="Verdana, Arial, Helvetica, sans-serif"><a href="http://www.tamaracchamber.org/"><font size="2" face="Verdana,Arial,Helvetica">  Tamarac Chamber of Commerce  </font></a></font>
      </li>
      </ul>
    </body>

    i established the font tag
    public class FontTag extends CompositeTag
    {
         private static final String[] mIds = new String[] {"FONT"};
         private static final String[] mEnders = new String[] {"FONT"};
         private static final String[] mEndTagEnders = new String[] {"BODY","HTML"};
        
         public String[] getIds () { return (mIds); }
    }

    and
       PrototypicalNodeFactory factory = (PrototypicalNodeFactory)t_parser.getNodeFactory();
        factory.registerTag(new FontTag());

    but i can' t get the text "Tamarac Chamber of Commerce ".
    i get the text "null".
    why?
    please help me!

     
    • Derrick Oswald

      Derrick Oswald - 2005-04-02

      You have two font tags, one embedded within the other.
      Are you looking at only the outermost one?
      If the outermost font tag is font, then:
        font.getChildren().elementAt (1);
      should get you the inner one (maybe it's not the second cilld).
      Then
        font.getChildren().elementAt (0);
      should get you the text node.

       
    • lilac

      lilac - 2005-04-03

      I find there exist some problem in <a> tag.
      The reason  i can't get the text in the inner tag<font > is  that i can't get the children in <a> tag
      LinkTag.getChildren() will return null.
      how i get the children of LinkTag?

       
      • Derrick Oswald

        Derrick Oswald - 2005-04-03

        It might have run into something that caused a virtual end tag insertion, but if we are talking about the previous HTML you posted, I see nothing that would cause LinkTag to end itself prematurely. Is that all the HTML or did you reduce it a bit for posting? A virtual end tag can be identified by the start and end positions being the same.

        A LinkTag will be ended by:
        enders: "A", "P", "DIV", "TD", "TR", "FORM", "LI" endtagenders: "/P", "/DIV", "/TD", "/TR", "/FORM", "/LI", "/BODY", "/HTML"

        Did you redefine LinkTag to have more Enders or EndTagEnders?

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.