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]

> 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?
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.
> 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?