taking element by element from an xml and finding average of the numbers

i am a beginner...i have got a module to complete...the module that i work on says that...

a request xml contains numbers in each child element nodes,i have to take these numbers from these nodes one by one and find their average.

ie

<Root>

<Calculate>

<P1>234</P1>

<P2>2456</P2>

:

:

:

<Pn>5634</Pn> (The number of rows is optional)

</Calculate>

</Root>

so this is the request...and the numbers from p1,p2..etc child elements have to taken and average of these has to be found using java program.

[641 byte] By [vyshnavea] at [2007-11-27 4:30:23]
# 1

> i am a beginner...i have got a module to

> complete...the module that i work on says that...

>

> a request xml contains numbers in each child element

> nodes,i have to take these numbers from these nodes

> one by one and find their average.

> ie

>

> <Root>

> <Calculate>

> <P1>234</P1>

> <P2>2456</P2>

> :

> :

> :

> <Pn>5634</Pn> (The number of rows is optional)

> </Calculate>

> </Root>

>

> so this is the request...and the numbers from

> p1,p2..etc child elements have to taken and average

> of these has to be found using java program.

This doesn't seem too difficult.

What is your question?

cotton.ma at 2007-7-12 9:39:38 > top of Java-index,Java Essentials,New To Java...
# 2

There are many XML readers which can read the file and prarsers that can extract the structure of the DTD.

With those two components, usually integrated into one "unit" will allow you to get the content of the elements. You can then use String or Number or Integer objects to get a native type from the string, i.e. "1" will return an int object with value of 1 or byte value 00000001 (1), etc. You can also get double values from strings like "0.0" then do the simple math (+, -, *, etc.) and poof.

watertownjordana at 2007-7-12 9:39:38 > top of Java-index,Java Essentials,New To Java...
# 3
i want to write the java code for this....could u plz help me on it....
vyshnavea at 2007-7-12 9:39:38 > top of Java-index,Java Essentials,New To Java...
# 4
> i want to write the java code for this....could u plz> help me on it....What is the difference between helping and giving you all the code?
cotton.ma at 2007-7-12 9:39:38 > top of Java-index,Java Essentials,New To Java...
# 5
> What is the difference between helping and giving you all the code?Several hours on the X-box.
floundera at 2007-7-12 9:39:38 > top of Java-index,Java Essentials,New To Java...
# 6
ok....i want the code for it
vyshnavea at 2007-7-12 9:39:38 > top of Java-index,Java Essentials,New To Java...
# 7
> ok....i want the code for itAnd how much will you pay for this code?
cotton.ma at 2007-7-12 9:39:38 > top of Java-index,Java Essentials,New To Java...
# 8
hii,the program i want is after i get elements from the xml...i have put it in a list and calculate the average....could u give me the code for that plz
vyshnavea at 2007-7-12 9:39:38 > top of Java-index,Java Essentials,New To Java...
# 9
> hii,the program i want is after i get elements from> the xml...i have put it in a list and calculate the> average....could u give me the code for that plzOk, I have your requirements. So, how much will you pay for this code?
cotton.ma at 2007-7-12 9:39:38 > top of Java-index,Java Essentials,New To Java...