<?xml version="1.0" encoding="utf-8"?>
<IndividualMAPPResults xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xml.assessment.com/Service/MAPPResults">
<MAPP_Member>
<MemberID>1234567890</MemberID>
<FirstName>John</FirstName>
<MiddleInitial/>
<LastName>Doe</LastName>
<Email>john...@example.com</Email>
<ErrorCode>0</ErrorCode>
</MAPP_Member>
</IndividualMAPPResults>
NSLog(@"DONE. Received Bytes: %d", [self.webdata length]);
NSString *theXML = [[NSString alloc]
initWithBytes: [self.webdata mutableBytes]
length:[self.webdata length]
encoding:NSUTF8StringEncoding];
//---shows the XML---
NSLog(@"%@", theXML);
NSError *err = nil;
DDXMLDocument *document = [[DDXMLDocument alloc] initWithXMLString:theXML options:0 error:&err];
DDXMLElement *rootElement = [document rootElement];
NSArray *docs=[rootElement nodesForXPath:@"//FirstName" error:&err];
NSLog(@"Doc Count %i",[docs count]);
for (DDXMLElement *documents in docs)
{
NSLog(@"First Name: %@", [documents stringValue]);
}
I should get back an array of 1 element and it should contain "John"
Thank you,
Loren
theXML = [theXML stringByReplacingOccurrencesOfString:@"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"" withString:@""];
theXML = [theXML stringByReplacingOccurrencesOfString:@"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" withString:@""];
theXML = [theXML stringByReplacingOccurrencesOfString:@"xmlns=\"http://xml.assessment.com/Service/MAPPResults\"" withString:@""];
Then the following call works:NSArray *docs=[rootElement nodesForXPath:@"//FirstName" error:&err];