0

i'm doing the rss reader and i need your help. I'm parsing an xml file and getting the next content of tag

<p>
    <img class="alignright size-full wp-image-115203" alt="10 мероприятий, которые можно посетить в марте" src="http://ain.ua/wp-content/uploads/2013/03/secr2011-nov1-300x200.jpg" width="300" height="200" title="10 мероприятий, которые можно посетить в марте"
    />Предлагаем вашему вниманию небольшой список ИТ мероприятий марта, которые пройдут в Украине. В нашем
    <a href="http://ain.ua/events">календаре мероприятий</a>, вы можете найти еще больше мероприятий, которые мы рекомендуем вам к посещению.</p>
<ol>
    <li>
        <a href="http://ain.ua/event/seminar-kpi-motivaciya-sistema-oplaty-po-rezultatu">Семинар “KPI-Мотивация. Система оплаты по результату”</a>
    </li>
    <li>
        <a href="http://ain.ua/2013/03/04/114970">Бесплатный семинар об организации системы внутренних коммуникаций и мотивации сотрудников</a>
    </li>
    <li>
        <a href="http://ain.ua/event/targetirovaniya-reklamnyx-kampanij-po-celevym-auditoriyam">Круглый стол «Возможности таргетирования рекламных кампаний по целевым аудиториям»</a>
    </li>
    <li>
        <a href="http://ain.ua/event/kak-zastavit-sajt-prodavat-bolshe">Бесплатный вебинар «Как заставить сайт продавать больше?»</a>
    </li>
    <li>
        <a href="http://ain.ua/event/6-j-seminar-effektivnyj-internet-marketing-dlya-biznesa">6-й семинар «Эффективный интернет-маркетинг для бизнеса»</a>
    </li>
    <li>
        <a href="http://ain.ua/event/internet-marketing-2013">Всеукраинский Форум «Дни Интернет-маркетинга» 2013</a>
    </li>

I need that all of these links where clickable and with name beetwen name_of_link

I have the next code, wich parsing needed xml-file

        ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>();

    String xml = XMLfunctions.getXML(resourceURL);
    Document doc = XMLfunctions.XMLfromString(xml);
    NodeList nodes = doc.getElementsByTagName("item");

    for (int i = 0; i < nodes.getLength(); i++) {                           
        HashMap<String, String> map = new HashMap<String, String>();    
        Element e = (Element)nodes.item(i);
        map.put(KEY_TITLE, XMLfunctions.getValue(e, KEY_TITLE));
        map.put(KEY_DATE_TIME, "Date: "+XMLfunctions.formatDate(XMLfunctions.getValue(e, KEY_DATE_TIME)));



        map.put(KEY_DESC, Html.fromHtml(XMLfunctions.getValue(e, KEY_DESC),null,null).toString());
        map.put(KEY_LINK, Html.fromHtml(XMLfunctions.getValue(e, KEY_LINK)).toString());
        mylist.add(map);            
    }       


    ListAdapter adapter = new SimpleAdapter(this, mylist , R.layout.main, 
                    new String[] { "title","pubDate", "description","link" }, 
                    new int[] { R.id.item_title, R.id.item_pubdate, R.id.item_subtitle, R.id.item_link });

    setListAdapter(adapter);

My question is : how to parse and transform data that in output i will get normal text with clickable links, like in this source http://feeds.feedburner.com/ainua?format=xml

I'm very sorry for wasting your time if this arcticle is already exist, but unfortunately, i don't know how to fing it. Any help is appreciated, because i've spend many hours trying to resolve this task, but i don't where i need to look for. Thx.

Emil
  • 7,220
  • 17
  • 76
  • 135

2 Answers2

0

I would try to implement my own Adapter-Class for the ListView and modify the views created for each row in the adapters corresponding method.

Benjamin K
  • 41
  • 6
  • i'm understanding you idea, but...could you give me some link on example, because i donn't know how i need to modify my views. Thx a lot for idea. – user2149862 Mar 08 '13 at 21:42
  • i have found how to place link like "Some text google into ListActivity(i have override the getView() method in my own MyArrayAdapter class that extends extends ArrayAdapter) and....it's show me link exactly what i need!...But there is another problem. Those link is not clickable )) ...(((..Could you tell where i need to look for, to make this link clickable? The content (for example, "Some text, google.com") in ListActivity container is not clickable. How to fix it? – user2149862 Mar 09 '13 at 18:29
0

You need to parse the HTML yourself if you don't want to use HTML.fromHTML(), while you can easily fetch the href links with RegEx, you still need to handle the image tags, lists, etc so RegEx is not the real answer. This question should help: Parse HTML in Android

In case you decide to try parsing the HTML with RegEx, please read: RegEx match open tags except XHTML self-co҉ntained tags. It explains why RegEx cannot do th̵is.

Community
  • 1
  • 1
Sam
  • 86,580
  • 20
  • 181
  • 179
  • Thx for another one idea how to parse html, i'm really appreciated for it, i'll use it. But my main question is how to display a lot of links like this one google in my own ListActivity class and make then clickable. Thx for your time. – user2149862 Mar 09 '13 at 16:25