Getting a parsing error after connecting to web service. I won't post that problem (yet) as I'm running down possible problems.

One that I noticed with displaying the individual GData elements, is that it is putting a "\" at the end of the element.

Example of what it should look like: "Element1"xxxxx""/Element1"

Example of what it doing: "Element1/"xxxxx""/Element1"

The quotes represent the less than and greater than symbols... I couldn't figure out how to get them to show here.

Have no idea what is causing this... any idea why?

Sample code:

GDataXMLElement *sellerElement = [GDataXMLNode elementWithName:@"Element1"];
GDataXMLElement *credElement = [GDataXMLNode elementWithName:@"Element2"];

[sellerElement addChild:credElement];

NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:path] cachePolicy:NSURLCacheStorageAllowedInMemoryOnly timeoutInterval:60];


[request setHTTPMethod:@"POST"];
[request setValue:@"733" forHTTPHeaderField:@"COMPATIBILITY-LEVEL"];
[request setValue:@"xxxxxxxxx" forHTTPHeaderField:@"API-DEV-NAME"];
[request setValue:@"yyyyyyyyy" forHTTPHeaderField:@"API-APP-NAME"];
[request setValue:@"GeteSomething" forHTTPHeaderField:@"API-CALL-NAME"];
[request setValue:@"0" forHTTPHeaderField:@"API-SITEID "];
[request setValue:@"text/mxl" forHTTPHeaderField:@"Content-Type"];

[request setHTTPBody:[xmldoc XMLData]];

NSURLResponse *response = nil;
NSError *error;
NSData *data = nil;
data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];

if ([data length] > 0)  {
    GDataXMLDocument *xmldoc = [[GDataXMLDocument alloc] initWithData:data options:0 error:&error];
    NSLog(@"Recieved  %@", xmldoc);
}
有帮助吗?

解决方案

After days of messing around with this, I found that it was all along my error.

Putting an NSLOG on sellerElement credElement, gives me the results above. The problem is that it was not complete, in that I didn't look at the results after adding (addChild) elements together, where the xml is all put together.

After putting a NLSOG on sellerElement, the results I was expecting was shown.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top