hpple icon indicating copy to clipboard operation
hpple copied to clipboard

node's parent is nil

Open vonbo opened this issue 12 years ago • 1 comments

my html code is like this:

And my objc code is: TFHpple* hpple = [TFHpple hppleWithHTMLData:data]; NSArray* links = [hpple searchWithXPathQuery:@"//a[@href!='']"]; for (TFHppleElement* link in links) { NSLog(@"link's parent: %@", link.parent); }

The output shows that the link's parent is nil, while it should be

  • node in this case. So is this a bug?
  • vonbo avatar Dec 16 '13 21:12 vonbo

    I believe that xPath starts recording at the "a" node. If you had started at the "ul" or "li" node then when you get to the "a" node, parent would contain the "li" node and the "li" node would, in turn, contain a parent as the "ul" node.

    premedios avatar Dec 17 '13 23:12 premedios