XML and Java from Beginner
Hi,
I am a Beginner, and need some help.
I am using .Net service and Java.
One of my webMethod can return an array of integer,
and the xml will looks like this:
<returnIntsResult>
<int>1</int>
<int>2</int>
<int>3</int>
</returnIntsResult>
How can I read all those integers?
Right now I am using the following java code and can only read the
first integer:
try {
// Since the Body.unmarshall() handler is static, we can't
// replace the basic machinery easily. Instead, we must obtain
// and parse the message on our own.
this.soapMessage_ = this.message_.receive();
XMLReader reader =
(XMLReader)Class.forName("org.apache.xerces.parsers.SAXParser").newInstance();
SAXHandler handler = new SAXHandler();
handler.setElementToSearchFor ("returnIntsResult");
// Set the Content Handler
reader.setContentHandler (handler);
// Parse the file
reader.parse ( new InputSource (new StringReader
(this.soapMessage_.getContent().toString() )));
// If we reached here, the result has been parsed and
// stored in the handler instance.
for(int i=0; i<3; i++){
returnValue[i]="";
returnValue[i] = handler.getResult();
}
}
catch (Exception exception) {
...........
Thank you for your help