Re: Help with this parse. can not seem to get what between the H3's

Derrick Oswald <[email protected]> Fri, 30 Mar 2012 21:48:33 +0200
Newsgroups gmane.comp.parsers.htmlparser.user
Message-ID <CAFVdc0DMEndFoDz2DmdQd9A9vX48Xk-7GUh2+YGhkRQe1O+Y-A@mail.gmail.com>
Oh, I see the problem now.
You need the recursive flag as the second argument to
extractAllNodesThatMatch:
public NodeList extractAllNodesThatMatch (NodeFilter filter, boolean
recursive)

On Wed, Mar 21, 2012 at 22:05, Randy Paries <[email protected]> wrote:

> hello,
> I have the snippet of html(see below) and i need to get the content of
> the <h3 id=h3_2.>
> there a bunch of these container divs with unqiue id's in my file.
> I can get the divs and their inner html just fine. I can not figure
> out how to get the whats between the H3 tags
>
> this snippet of code works for divs but not the h3:
> if finds the h3 with the correct ID, i just can not figure out how to
> get the innerHTML or whats between the <h3> tags.
>
> thanks for any help
>
>
> ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> //tag = is the container_2 info
>
>                  innerparser = new Parser();
>                  innerparser.setInputHTML(tag.toHtml());
>                  innerparser.setEncoding("UTF-8");
>                  innerNodes = innerparser.extractAllNodesThatMatch(
> new TagNameFilter("h3") );
>                  for (int x=0; x<innerNodes.size(); x++){
>                      TagNode itag = (TagNode)innerNodes.elementAt(x);
>                      String innerIdAttribute = itag.getAttribute("id");
>                      if ( innerIdAttribute != null &&
> innerIdAttribute.equals( "h3_"+num )  ){
>                          System.out.println("id-->"+innerIdAttribute);
>                          h3Data = itag.toHtml();
>                      }
>                  }
>
>
>
> ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>        <div class="container" id="container_2">
>                   <h3 id="h3_2">Adding a few</h3>       <div
> class="maindiv" id="div_2">
>        ...new articles in here jus tto flesh it out.
>                   </div><!--end of div_2-->
>                   <div class="stardiv" id="star_2">
>                          <a class="aEdit"
> href="javascript:editSection('div_2',2);"><img
> src="images/edit.png" border=0></a>
>                          <a class="aDelete"
> href="javascript:deleteSection('container_2',2);"><img
> src="images/delete.png" border=0></a>
>                   </div><!--end of star_2-->
>        </div>
>
> ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>
> ------------------------------------------------------------------------------
> This SF email is sponsosred by:
> Try Windows Azure free for 90 days Click Here
> http://p.sf.net/sfu/sfd2d-msazure
> _______________________________________________
> Htmlparser-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/htmlparser-user
>

------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure

_______________________________________________
Htmlparser-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/htmlparser-user