# Objective-C-HTML-Parser **Repository Path**: mirrors/Objective-C-HTML-Parser ## Basic Information - **Project Name**: Objective-C-HTML-Parser - **Description**: Objective-C-HMTL-Parser 是一个用 ObjectiveC 编写的简易 HTML 解析器 - **Primary Language**: Objective-C - **License**: Not specified - **Default Branch**: master - **Homepage**: https://www.oschina.net/p/objective-c-html-parser - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-09-04 - **Last Updated**: 2025-09-06 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README 1. Open Your project in XCode and drag and drop all .h & .m Files into an appropriate folder 2. In the project settings add "/usr/include/libxml2" to the "header search paths" field 3. Ctrl Click the Frameworks group choose Add -> Existing Frameworks and from the list choose libxml2.dylib Example Usage ============= ```objc NSError *error = nil; NSString *html = @"" "Hello World 1" "Hello World 2"; HTMLParser *parser = [[HTMLParser alloc] initWithString:html error:&error]; if (error) { NSLog(@"Error: %@", error); return; } HTMLNode *bodyNode = [parser body]; NSArray *inputNodes = [bodyNode findChildTags:@"input"]; for (HTMLNode *inputNode in inputNodes) { if ([[inputNode getAttributeNamed:@"name"] isEqualToString:@"input2"]) { NSLog(@"%@", [inputNode getAttributeNamed:@"value"]); //Answer to first question } } NSArray *spanNodes = [bodyNode findChildTags:@"span"]; for (HTMLNode *spanNode in spanNodes) { if ([[spanNode getAttributeNamed:@"class"] isEqualToString:@"spantext"]) { NSLog(@"%@", [spanNode rawContents]); //Answer to second question } } [parser release]; ```