firstChild
またはよりも配列のさらに下の要素を取得するにはどうすればよいですか?parent
NSString *tutorialsXpathQueryString = @"//table/tr/td/ancestor::table[1]";
// @"//tr/td/table/tr/td/a"
NSArray *tutorialsNodes = [tutorialsParser searchWithXPathQuery:tutorialsXpathQueryString];
NSLog(@"here is url: %@", tutorialsNodes);
NSMutableArray *newTutorials = [[NSMutableArray alloc] initWithCapacity:0];
for (TFHppleElement *element in tutorialsNodes) {
// 5
Tutorial *tutorial = [[Tutorial alloc] init];
[newTutorials addObject:tutorial];
tutorial.url = [[element parent] objectForKey:@"style"];
//tutorial.url = [element objectForKey:@"style"];
//tutorial.url = [[element firstChild] objectForKey:@"style"];
//tutorial.url = [element tagName];
tutorial.title = [[element parent] objectForKey:@"title"];
//tutorial.title = [element objectForKey:@"title"];
//tutorial.title = [[element firstChild] objectForKey:@"title"];
//tutorial.title = [[element firstChild] tagName];
私の配列のサンプル:
{\n nodeAttributeArray = (\n {\n attributeName = style;\n nodeContent = \"background-color: #008000; border-style: none;\";\n },\n {\n attributeName = border;\n nodeContent = 0;\n },\n {\n attributeName = cellpadding;\n nodeContent = 2;\n },\n {\n attributeName = cellspacing;\n nodeContent = 2;\n }\n );\n nodeChildArray = (\n {\n nodeChildArray = (\n {\n nodeChildArray = (\n },\n {\n attributeName = border;\n nodeContent = 0;\n },\n {\n attributeName = src;\n nodeContent = \"https://spacer.gif\";\n },\n {\n attributeName = title;\n nodeContent = \"07:00,24hrs: B Shift /.../E704/RS704/Firefighter #2\";\n },\n {\n attributeName = alt;\n nodeContent = \"07:00,24hrs: B Shift /.../E704/RS704/Firefighter #2\";\n }\n );\n nodeName = img;\n }\n );\n nodeName = td;\n },\n