Now I'm doing it like:
NodeList* elementsUsingTagG = [third_floor.DOMDocument getElementsByTagName:@"g"];
auds = [elementsUsingTagG.internalArray objectAtIndex:1];
SVGElement *elem = (SVGElement*)[third_floor.DOMDocument getElementById:hitLayer.name];
if ([auds.childNodes.internalArray containsObject:elem])
{
[self deselectTappedLayer];
lastTappedLayer = hitLayer;
if (lastTappedLayer != nil)
{
lastTappedLayer.opacity = 1.0f;
NSLog(@"Clicked on auditory %@, highlight it!", hitLayer.name);
}
}
Can I get some property of SVGElement/CALayer/Node, which identifies group, which this elem belongs to? Thanks
Something like this i guess. I haven't tested the code but i hope it can help you.
Iterative version:
- (Element *)findFirstParentElementFromNode:(Node *)node
withTagName:(NSString *)tagName {
for (node = node.parentNode; node != nil; node = node.parentNode) {
if (![node isKindOfClass:[Element class]]) {
continue;
}
Element *element = (Element *)node;
if([element.tagName isEqualToString:tagName]) {
return element;
}
}
return nil;
}
Recursive version:
- (Element *)findFirstParentElementFromNode:(Node *)node
withTagName:(NSString *)tagName {
if (node.parentNode == nil) {
return nil;
}
if ([node.parentNode isKindOfClass:[Element class]]) {
Element *element = (Element *)node.parentNode;
if([element.tagName isEqualToString:tagName]) {
return element;
}
}
return [self findFirstParentElementFrom:node.parentNode
withTagName:tagName];
}
And use one of them like this in your case:
Element *groupElement = [self findFirstParentElementFromNode:elem
withTagName:@"g"];