TFHpple XML returning NULL

east0n

New Member
I'm having trouble with TFHpple and performing a basic XML search query. I've included the code and the XML response. I have a MutableArray that stores the data that is returned and then I NSLog it. This following code has worked just fine for me before when parsing an HTML page (of course I used initWIthHTMLData: instead). Any help would be greatly appreciated. \[code\] NSData *data = http://stackoverflow.com/questions/10703885/[[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:@"http://api.wmata.com/Rail.svc/Stations? LineCode=RD&api_key=---------------------------"]];// Create parserTFHpple *xpathParser = [[TFHpple alloc] initWithXMLData:data]; //using XML data//Pass in the search pathNSArray *elements = [xpathParser searchWithXPathQuery:@"//Name"];// Access the first cellif([elements count] > 0) { TFHppleElement *element = [elements objectAtIndex:0]; // Get the text within the cell tag NSString *content = [element content]; if (content) { //NSLog(@"%@", content); self.linkElements = [elements copy]; }else{ NSLog(@"No string found in the content"); }}else{ NSLog(@"Nothing was found for your search query");}NSLog(@"The following is the result of the link elements array: %@", self.linkElements);\[/code\]The following is an example xml response:\[code\] <StationsResp xmlns="http://www.wmata.com" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><Stations><Station> <Code>C02</Code> <Lat>38.9013327968</Lat> <LineCode1>BL</LineCode1> <LineCode2>OR</LineCode2> <LineCode3 i:nil="true" /> <LineCode4 i:nil="true" /> <Lon>-77.0336341721</Lon> <Name>McPherson Square</Name> <StationTogether1 /> <StationTogether2 /></Station><Station> <Code>C01</Code> <Lat>38.8983144732</Lat> <LineCode1>BL</LineCode1> <LineCode2>OR</LineCode2> <LineCode3 i:nil="true" /> <LineCode4 i:nil="true" /> <Lon>-77.0280779971</Lon> <Name>Metro Center</Name> <StationTogether1>A01</StationTogether1> <StationTogether2 /></Station><Station> <Code>A01</Code> <Lat>38.8983144732</Lat> <LineCode1>RD</LineCode1> <LineCode2 i:nil="true" /> <LineCode3 i:nil="true" /> <LineCode4 i:nil="true" /> <Lon>-77.0280779971</Lon> <Name>Metro Center</Name> <StationTogether1>C01</StationTogether1> <StationTogether2 /></Station>...\[/code\]
 
Back
Top