Question

I am using a website to find if a word exists or not in the romanian language. So i am creating an NSXMLParser with the following url: http://dexonline.ro/definitie/caine

But the parser goes through the <head> element names and not through the <body> and i cant tell if the word was found.

- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict {

    NSLog(@"%@",elementName);
}

The parser never reaches the body. What can i do ?

Was it helpful?

Solution

NSXMLParser is probably not the correct tool for the job. It requires accurate XML input and often HTML from websites isn't accurate enough (missing tags / bad encoding / etc).

Instead, you may want to:

  1. Find a different parser that is more free and easy about accuracy
  2. Load into a web view and use javascript to find your content
  3. Use NSScanner to locate and extract your content
  4. Find a service which offers a proper API rather than trying to scrape the results
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top