You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Update: I’ve fixed this by implementing two new methods, childElementsWithCSSSelector and selectChildElements, for restricting CSS selector searches to just the children of the specified element.
Update #2 I’ve also added methods for childElementWithCSSSelector and selectChildElement (singular/first match versions of the above and sent over a second pull request!) :)
Original post follows:
If I have a structure:
<a>
<b></b>
<b></b>
<b>
<b>
</b>
</b>
</a>
Where b nodes may contain other b nodes, I can get an NSArray of b nodes with NSArray *elements = [doc selectElements:@"a > b"]. However, when I want to loop through those elements to get their child b elements, I’m getting the full list of b elements (both children of that b element and siblings of b):
for (Element *element in elements) {
// This should only get second-level b elements but doesn't.
childBElements = [element selectElements:@"b"];
NSLog(@"%@", childBElements);
}
I would expect selectors on a node to be scoped to that node and its children only (not siblings) but this doesn’t appear to be the case.