开发者

Android html parsing application htmlcleaner

Hi its my first post here I am writing it because I went throught every example google knows about on htmlcleaner... and I cant get my project running ;( Im tryng to make an Android app fetching and displaying data from flash rich webpage. The idea is to get only the most important data so that users wouldnt wast time, money processing power, nerves on atempting to brawse those pages on their smartphones... Its a country specific webpage... therefore country pecific app. On the page i want to parse there is this part

    <li class="genre-3 genre-7 genre-9 mi-37 ">
    <a href="http://some_link.co"; class="image"><img src="picture.jpg" alt="altTitle"></a>
    <div class="superClass"> 
       <a> aaa </a> 
       <a href="http://some_link_2.co"> bbb </a> 
       <a href="http://some_link_3.co"> ccc </a>
       <a href="http://some_link_4.co"> ddd </a> 
       <a href="http://some_link_5.co"> eee </a> 
    </div>
    <h2><a href="http://some_other_link" class="title">title_of_super_product</a></h2>
    <ul class="icons tooltip-enabled">
       <li class="before"></li>
       <li><img src="15_2.png" alt="15_2"></li>
    </ul>
    <div> </div> 
    <span class="material">some_material</span> 
    <span class="price">0.1USD</span>
    <p class="text"> Some description </p> 
     <a class="button-more" href="http://link_to_more_info"></a> 
    </li>

The above is a ListItem, there are others similiar on the webpage. I have java class ready to fill it with data from the li lements. One clsss object for one li element. I need to extract the description, price, material, image links, stuff from superClass , meaning aaa,bbb,ccc,ddd, etc... The big question is how to do that? I thought that if i start from making a array that would consist of li elements i would be able to search each 开发者_Go百科of them further for subelements i need... but it doest work ;(

    TagNode[] liElements = rootNode.getElementsByName("li", true);
    for (int i=0; liElements != null && i < liElements.length; i++) {   
    if(liElements.getAttributeByName("class").contains("genre"))   
    Log.d("li",liElements.getAttributeByName("class")); }

Gives only the first li element, then it spams nullPointerExceptions in the console Please please help, Im hopeless ;(;(;(


String classType =liElements.getAttributeByName("class");
if(classType!=null && classType.equals("genre........");
liElements[i]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜