VKSingh
VKSingh

Reputation: 452

can i parse Soap parsing this type?

How to parse Options tag with name tag and my arraylist make as a this type

 [[anyType{}],[Sandy,Mark,Tayler,Waine],[mark Henry]]


FetchFormResponse
{
FetchFormResult=anyType
{
Formlist=anyType
{

Form=anyType
{
Name=Form; Id=6; Options=anyType{};
 }; 

Form=anyType
{
Name=Form1; Id=7; 
Options=anyType
{
Option=anyType{Name=Sandy; Id=154; Type=TextBox; Value=anyType{};
 }; 
Option=anyType
{
Name=Mark; Id=155; Type=TextBox; Value=anyType{};
 };
 Option=anyType
{
Name=Tayler; Id=156; Type=TextArea; Value=anyType{}; 
};
 Option=anyType
{
Name=Waine; Id=157; Type=CheckBox; Value=Master,Graduate; 
};
 };

Form=anyType
 {
Name=Form2; Id=9; 
Options=anyType
{
Option=anyType
{
Name=Mark Henry; Id=185; Type=Checkbox; Value=anyType{};
 };
};
 }; 

 }; 
}; 
};
 }

Would be very cool to know if somebody solved this issue and how. Thanks.

Upvotes: 1

Views: 147

Answers (2)

arenko
arenko

Reputation: 174

You have to create soap objects and get responses from there, like:

SoapObject response= (SoapObject) envelope.bodyIn; 
SoapObject result= (SoapObject) response.getProperty(0);
SoapObject list= (SoapObject) result.getProperty(0);
SoapObject form= (SoapObject) list.getProperty(0);
SoapObject options= (SoapObject) form.getProperty("Options");
for(int i=0; i<options.getPropertyCount(); i++){
SoapObject option= (SoapObject) options.getProperty(i);
String name = option.getPropertyAsString("Name");
array.add(name);
}

this should work

Upvotes: 1

Amalan Dhananjayan
Amalan Dhananjayan

Reputation: 2287

I really don't know whether this will help you as this is in KSoap and yours looks like JASON.As I am using basic java operations it wont be any differences

Get the results as a string and do the use pattern matching to extract the data you wanted

String r = NameArray.columncount("userid", limitstart, loadNumber,loggername);
String temp = r.replaceAll(";\\s", ",").replaceAll("string=", " ")
.replace("anyType{", "").replace(",}", "");
String[] fulname = temp.split(",\\s+");

for step by step instruction please refer this site How to process an array returned from WSDL

Upvotes: 0

Related Questions