Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Trusted Contributor
Posts: 204
Registered: ‎07-14-2010
My Device: 8100
My Carrier: Blackberry developer
Accepted Solution

parse 2 elements at a time USING DOM

Is it possible yo parse two elements from an rss , say title , description

at this line .. ?

 

 

NodeList list = doc.getElementsByTagName("Title");

 

here i need to parse "description" also from rss ,hw to do this ?

any ideas ?

i need to implement this with DOM parser

Developer
Posts: 70
Registered: ‎01-02-2009
My Device: Not Specified

Re: parse 2 elements at a time USING DOM

NodeList list = doc.getElementsByTagName("Title");

 

This will list all the "Title" elements from the rss xml.

 

Like that you have to get all the elements and then you can get  the description.

 

NodeList descList = doc.getElementsByTagName("description_tag name");

 

---------------------
Best Regards,
Kannabiran.
---------------------
Don't forget to mark your post as solved if you got answer. And give kudos.
Trusted Contributor
Posts: 204
Registered: ‎07-14-2010
My Device: 8100
My Carrier: Blackberry developer

Re: parse 2 elements at a time USING DOM

fine , can this be implemented in the same thread ?

or i need to create a seperate one.?

Developer
Posts: 70
Registered: ‎01-02-2009
My Device: Not Specified

Re: parse 2 elements at a time USING DOM

yes.

---------------------
Best Regards,
Kannabiran.
---------------------
Don't forget to mark your post as solved if you got answer. And give kudos.
Trusted Contributor
Posts: 204
Registered: ‎07-14-2010
My Device: 8100
My Carrier: Blackberry developer

Re: parse 2 elements at a time USING DOM

yes for , creating a different one ?

Highlighted
Developer
Posts: 70
Registered: ‎01-02-2009
My Device: Not Specified

Re: parse 2 elements at a time USING DOM

[ Edited ]

If you want to use it in a new thread, you have to create a new thread and parse the description in that thread.

 

Please mark the thread solved, if your problem is solved.

---------------------
Best Regards,
Kannabiran.
---------------------
Don't forget to mark your post as solved if you got answer. And give kudos.
Trusted Contributor
Posts: 204
Registered: ‎07-14-2010
My Device: 8100
My Carrier: Blackberry developer

Re: parse 2 elements at a time USING DOM


 ve implemented it in the same thread one for title and another node for description , and in drawlistrow function ve coded as ,

 

String text = (String)listElements.elementAt(index);

 

String str1 = text.substring(0,text.indexOf("-"));

g.drawText(str1, xpos, ypos);

 

 

 

will this work out ?

Regular Contributor
Posts: 89
Registered: ‎07-13-2010
My Device: 8700

Re: parse 2 elements at a time USING DOM

NodeList list = document.getElementsByTagName("ConName");
  NodeList ls = document.getElementsByTagName("Con4");
.

.

.

 

 

for (int i=0;i<list.getLength();i++){
    
    Node value=list.item(i).getChildNodes().item(0);
    Node val=ls.item(i).getChildNodes().item(0);

 

if (value !=null){
                 listfield.insert(i,new LabelField());
                 v.addElement(value.getNodeValue());
                 v1.addElement(val.getNodeValue());
                 }

.

.

.

.

 

 

public void drawListRow(ListField list, Graphics g,  int index, int y, int w)
{
                String text=(String)v.elementAt(index);
                g.drawText(text,0,y,0,w);
              
                String text1=(String)v1.elementAt(index);
                g.drawText(text1,0,y,DrawStyle.RIGHT,w);
               }

 

public void insert(String toInsert) {
          v.insertElementAt(toInsert,0);
     v1.insertElementAt(toInsert,0);
       }

 

 

dis is wat i did 2 parse two elements using dom...

Trusted Contributor
Posts: 204
Registered: ‎07-14-2010
My Device: 8100
My Carrier: Blackberry developer

Re: parse 2 elements at a time USING DOM

may i know wat is v and v1 here,

v.addElement(value.getNodeValue());
                 v1.addElement(val.getNodeValue());

Trusted Contributor
Posts: 204
Registered: ‎07-14-2010
My Device: 8100
My Carrier: Blackberry developer

Re: parse 2 elements at a time USING DOM

i get an error in thread at insert of this line ,

_list.insert(i,new LabelField());