Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

node's parent is nil #38

Open
vonbo opened this issue Dec 16, 2013 · 1 comment
Open

node's parent is nil #38

vonbo opened this issue Dec 16, 2013 · 1 comment

Comments

@vonbo
Copy link

vonbo commented Dec 16, 2013

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?

  • @premedios
    Copy link
    Collaborator

    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.

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    None yet
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants