Yes! You help me a lot. Thank you very much.

-----Original Message-----
From: Man, Tsjok-Wing [mailto:[EMAIL PROTECTED] 
Sent: Friday, March 05, 2004 4:59 PM
To: '[EMAIL PROTECTED]'
Subject: RE: [Newbie Question]Parsing a text/xml result

Hello,

The xmlrpc.execute call will create the necessary structures
automatically
for you. There's a list of mappings between Java types and XMLRPC-types
in
the documentation somewhere. You don't have to parse the XMLRPC response
yourself, that's what the xmlrpc-library is for! 

for example the following response:
<methodResponse>
        <params>
                <param>
                        <value>
                                <array>
                                        <data>
                                                <value>
                                                        <struct>
                                                                <member>
        
<name>org</name>
        
<value><string>Foo</string></value>
        
</member>
                                                                <member>
        
<name>country</name>
        
<value><string>Holland</string></value>
        
</member>
                                                        </struct>
                                                </value>
                                                <value>
                                                        <struct>
                                                                <member>
        
<name>org</name>
        
<value><string>Bar</string></value>
        
</member>
                                                                <member>
        
<name>country</name>
        
<value><string>UK</string></value>
        
</member>
                                                        </struct>
                                                </value>
                                        </data>
                                </array>
                        </value>
                </param>
        </params>
</methodResponse>

This will be automatically mapped by xmlrpc to a Vector containing two
Hashtables.

So your code will need to cast the result to a Vector first:
Vector result;

result = (Vector) xmlrpc.execute ("method.name", params);

And to get the info out:
Iterator results;
results = result.iterator();
while (results.hasNext()) {
        Hashtable organisation = (Hashtable) results.next();
        System.out.println("org name: " + organisation.get("org"));
        System.out.println("org country: " +
organisation.get("country"));
}

This will print:
org name: Foo
org country: Holland
org name: Bar
org country: UK

Hope this helps,

Regards,

Tsjok

-- 
drs. Tsjok-Wing Man 
Ordina Software Integration & Development 
Consultant ICT 
____________________________________________________________________ 
Ordina SI&D Technology Consulting    Tel: (033) 434 16 00 
Plotterweg 1                         Fax: (033) 494 58 45 
3821 BB Amersfoort                   GSM:  06 53 37 56 05 
URL: http://www.ordina.nl/           Email: [EMAIL PROTECTED] 
____________________________________________________________________ 
-----Oorspronkelijk bericht-----
Van: bagas [mailto:[EMAIL PROTECTED]
Verzonden: vrijdag 5 maart 2004 10:55
Aan: [EMAIL PROTECTED]
Onderwerp: [Newbie Question]Parsing a text/xml result


Dear all,
 
Suppose I have sent a remote procedure call
 
String result = (String) xmlrpc.execute ("method.name", params);
 
And get result. 
 
The result itself is a String containing a XML-RPC message.
 
The Question is how can I extract the Result XML to Vector or an array?
 
Thank you very much.
 
 
 
 


Reply via email to