parsing - Titanium - xml attribute find and replace -


i working in titanium mobile , im trying parse , xml feed. feed parses fine, looking exact attributes such title, author, , description. every often, feed not supplied 1 of items im looking for. instance, title , description present in item, author missing because there never 1 supplied.

example

<item>     <title></title>     <author></author>     <desc></desc> <item> <item>     <title></title>     <desc></desc> <item> 

notice author missing in second item. code error out "result of expression "author".item(0)'[null] not object."

how skip attribute if doesn't exist?

i used following code resolve issue.

if(items.item(i).getelementsbytagname('author').length > 0){ //do } 

Comments