Menu

How to remove comments and particular tags

Help
Madhu
2006-04-04
2013-04-27
  • Madhu

    Madhu - 2006-04-04

    Hi  to ALL

    Already I posted My problem with example And  Subject is ::Look at This (Urgent)..................
    I think its very lengthy

    The  problems are

    1.how to remove Comments
    2.How to remove span tags
    3.How to retrieve data from Font tags? Like <td>Vaio FS750/<font   class="font20">$100</font>
    </td>
    Means need to get like   Vaio FS750$100

    4.How to remove Empty Tags <td></td>

    sample code As Follows::

    FilterBean fb = new FilterBean();
    fb.setURL ("c:/html/price.htm");
    fb.setFilters (new NodeFilter[] { new tagNameFilter ("TR") });
    NotFilter filter=new NotFilter(new TagNameFilter("SPAN"));
    NodeList list=fb.getNodes ();
    list.extractAllNodesThatMatch(filter,true);

    It in again displaying span tags when iam writing into Excel sheet like::
    iMac<span   style='mso-spacerun:yes'> </span>   

           

    Plz Help Me Soon

    rgds
    Madhu

     
    • Derrick Oswald

      Derrick Oswald - 2006-04-04

      Comments are returned as RemarkNode and can be identified with
        instanceof RemarkNode

      Removing a composite tag like SPAN menas replacing the occurance of that tag by it's list of children.
      See the NodeList documentation for manipulating the list of child nodes.

      Similar for FONT and empty tags.

       
      • Madhu

        Madhu - 2006-04-07

        Thanks for ur Reply

        But iam unable to get it
        FilterBean fb = new FilterBean();
        fb.setURL ("d:/html/check.htm");
        fb.setFilters (new NodeFilter[] { new TagNameFilter ("TR") });
        NodeList list=fb.getNodes ();
        RemarkNode rkNode=new RemarkNode("<!-- -->");
        for (int i =0,j=0;i<list.size();i++)
        //for
        {
        Node node=(Node)list.elementAt(i);
        TableRow tr=(TableRow)node;
        int tdLength=tr.getColumnCount();
        if(tdLength==2)
        {
        TableColumn[] tc=tr.getColumns();
        for(int k=0;k<tc.length;k++)
        {
        if(k==0||k==1)
        {
        if(tc[k].getChild(k) instanceof RemarkNode)
            {
                tc[k].removeChild(k);
                 }
        if(tc[k].getChild(k) instanceof Span)
             {                             tc[k].removeChild(k);
             }
        }
        System.out.println(tc[k].getStringText());
        When iam printing above statement iam getting same data ,they are not removing

        Plz send some sample code for that

        Can we apply 2 filters at a time ?

        FilterBean fb = new FilterBean();
                fb.setURL ("d:/html/price.htm");
                fb.setFilters (new NodeFilter[] { new TagNameFilter ("TR") });
        NodeFilter filter=new NotFilter(new TagNameFilter("SPAN"));
        NodeList list=fb.getNodes ();
        list.extractAllNodesThatMatch(filter,true);

        When iam extracting values into excel sheet again iam getting same data

        Plz help me --------------

                           

         

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.