XML parsing prob

by eyedol » Wed, 03 Dec 2008 12:51:43 GMT


Sponsored Links
 Can't figure out how to achieve this. I was to get the values for the
tag "thumb" it works fine if the "thumb" tag shows once, but if it
increases, I get an exception thrown. Exception
java.lang.IndexOutOfBoundsException: Invalid location 1, size is 1

Sample xml
<response>

<payload>

<jobs>

<job0>

<job>
<jobid>1</jobid>
<jobtitle>The book</jobtitle>

<jobdescription>
An enterprise or desktop gateway that connects data sources to mobile
networks. Intelligent routing can map messages via GSM modems or SMPP
connections to the lowest-cost delivery channel. Routing by service
and content provider is also configurable. Offline versions for off-
net delivery via modems is available.
</jobdescription>
<locationid>1</locationid>
<locationname>Addis</locationname>
<categoryid>2</categoryid>
<categorytitle>White Color</categorytitle>
</job>

<media>

<mediaitem0>
<id>1</id>
<title/>
<type>1</type>
<thumb>1_1_12277.jpg</thumb>
</mediaitem0>

<mediaitem1>
<id>8</id>
<title/>
<type>1</type>
<thumb>1_1_12282.jpg</thumb>
</mediaitem1>
</media>
</job0>
</jobs>
</payload>

<error>
<code>0</code>
<message>No Error</message>
</error>
</response>

The Java code to fetch the values
...
NodeList thumbnails = doc.getElementsByTagName("thumb");

                for (int i=0;i< thumbnails.getLength();i++) {

                        Element thumbnail= (Element) thumbnails.item(i);
                        Job job = jobs.get(i);
                        t +=thumbnail.getFirstChild().getNodeValue()+",";
                        Job.setThumbnail(t);
                }
...

All I want to achieve is get the values for the thumb tag. What am I
doing wrong and how do I achieve that.
--~--~---------~--~----~------------~-------~--~----~



XML parsing prob

by Xavier Mathews » Wed, 03 Dec 2008 13:17:16 GMT


 I Believe This Is In The Archives.





-- 
Xavier A. Mathews
Student/Browser Specialist/Developer/Web-Master
Google Group Client Based Tech Support Specialist
Hazel Crest Illinois
[EMAIL PROTECTED]@[EMAIL PROTECTED]
"Fear of a name, only increases fear of the thing itself."

--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


XML parsing prob

by eyedol » Wed, 03 Dec 2008 15:09:55 GMT


 I have dug this list but didn't come across anything similar to mine.
Could you point me to a thread?




--~--~---------~--~----~------------~-------~--~----~



XML parsing prob

by Mark Murphy » Wed, 03 Dec 2008 21:02:29 GMT


 


<snip>


You didn't indicate where the exception occurred. That would be useful 
information for us folk out here, to better help you out.

Off the cuff, I don't see a problem in your for() loop.

The only thing that seems strange is your thumbnail logic. With String t 
presumably declared well outside the loop, and the use of t+=, you are 
calling a static setThumbnail() function with one thumbnail on the first 
job, two thumbnails on the second job, three thumbnails on the third 
job, etc. So, I'm guessing perhaps the exception is occurring somewhere 
inside setThumbnail(). But that's just a guess.

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com 

Android Training on the Ranch! -- Mar 16-20, 2009
 http://www.bignerdranch.com/schedule.shtml 

--~--~---------~--~----~------------~-------~--~----~



XML parsing prob

by Digestor » Thu, 04 Dec 2008 00:56:36 GMT


 I  guess the problem is in this line:

Job job = jobs.get(i);

I seems to me (according to your xml sample) that there is only one
job. So in the second run of the for-loop the
IndexOutOfBoundsException-Exception occurs.

Good luck

--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Qestion about Android Build System

HI Folks:
     I know I scrubed up my android build system, but have no clue to trace
the problem.
Hope you can share some lights on me.
     Here is my problem, when compile bionic (libc).
I find that the generated libc.a file doesn't include libc_common.a
so some function symbols are missing when come to the final link stage.

Android.mk ( I assume libc.a will include link libc_common.a)

LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
LOCAL_MODULE := libc

$ mips-linux-gnu-objdump -t
out/target/product/generic/obj/STATIC_LIBRARIES/libc_intermediates/libc.a
|grep ABS
mips-linux-gnu-objdump: libc_common.a: File format not recognized
00000000 l    df *ABS*    00000000 /mydroid/bionic/libc/bionic/dlmalloc.c
00000000 l    df *ABS*    00000000
/mydroid/bionic/libc/bionic/libc_init_static.c
00000000 l    df *ABS*    00000000 /mydroid/bionic/libc/bionic/malloc_leak.c

 note:
   mips-linux-gnu-objdump: libc_common.a: File format not recognized

Dennis

-- 
unsubscribe: android-porting+unsubscr...@googlegroups.com
website: 

2. IWIC indosat

Ada boss, ada 3 member milis id-android yg masuk finalis android :-)



Salam Android,

Agus Hamonangan

-----Original Message-----
From: "9b.andr...@gmail.com" <9b.andr...@gmail.com>
Date: Mon, 2 Nov 2009 19:36:51 
To: <id-android@googlegroups.com>
Subject: [id-android] IWIC indosat

Nah tuh dah  ada finalisnya, ada anak milus ngga?

Salam,

Lucky Sebastian
-me @google android-



--~--~---------~--~----~------------~-------~--~----~
Google Groups "Indonesian Android Community [id-android]" group.

To post to this group, send email to id-android@googlegroups.com

To request to subscribe to this group:

Click  

3. playing media files, from prebuilt android binaries

4. Stable contact identity & CONTENT_LOOKUP_URI

5. Problem running a compiled/packaged-with-v1.6 application on v1.5

6. Persisting a context menu after screen rotation

7. No rule to make target 'iso_img'