mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-04-16 10:48:50 +00:00
Monotone-Parent: 5700ac30588b73b584a91318efc00fb0469e6c98
Monotone-Revision: 5db95c823716f08780a1e57b51f753d465c61194 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2009-06-18T20:26:32 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
@@ -25,16 +25,16 @@
|
||||
|
||||
#import <DOM/DOMNode.h>
|
||||
|
||||
@interface NGDOMNodeWithChildren (SOGoDOMExtensions)
|
||||
@interface NGDOMNodeWithChildren (SOGoDOMExtensions) < DOMNode >
|
||||
|
||||
- (id <DOMNodeList>) childNodesWithTag: (NSString *) tagName;
|
||||
- (id <DOMNodeList>) childNodesWithTag: (NSString *) tagName
|
||||
inNamespace: (NSString *) namespace;
|
||||
|
||||
- (id<NSObject,DOMNode>) firstNodeWithTag: (NSString *) tagName;
|
||||
- (id<NSObject,DOMNode>) firstNodeWithTag: (NSString *) tagName
|
||||
- (id <DOMNodeList>) childElementsWithTag: (NSString *) tagName;
|
||||
- (id <DOMNodeList>) childElementsWithTag: (NSString *) tagName
|
||||
inNamespace: (NSString *) namespace;
|
||||
|
||||
- (id <DOMElement>) firstElementWithTag: (NSString *) tagName;
|
||||
- (id <DOMElement>) firstElementWithTag: (NSString *) tagName
|
||||
inNamespace: (NSString *) namespace;
|
||||
|
||||
@end
|
||||
|
||||
#endif /* S_GO_SOOBJECTS_SOGO_DOMNODE_SOGO_H */
|
||||
|
||||
@@ -29,40 +29,41 @@
|
||||
|
||||
@implementation NGDOMNodeWithChildren (SOGo)
|
||||
|
||||
- (id <DOMNodeList>) childNodesWithTag: (NSString *) tagName
|
||||
inNamespace: (NSString *) namespace
|
||||
- (id <DOMNodeList>) childElementsWithTag: (NSString *) tagName
|
||||
inNamespace: (NSString *) namespace
|
||||
{
|
||||
id <DOMNodeList> nodes;
|
||||
NSMutableArray <DOMNodeList> *childNodesWithTag;
|
||||
id <NSObject, DOMNode> currentNode;
|
||||
NSMutableArray <DOMNodeList> *childElementsWithTag;
|
||||
id <DOMElement> currentElement;
|
||||
unsigned int count, max;
|
||||
|
||||
childNodesWithTag = [NSMutableArray array];
|
||||
childElementsWithTag = [NSMutableArray array];
|
||||
|
||||
nodes = [self childNodes];
|
||||
max = [nodes length];
|
||||
for (count = 0; count < max; count++)
|
||||
{
|
||||
currentNode = [nodes objectAtIndex: count];
|
||||
if ([[currentNode nodeName] isEqualToString: tagName]
|
||||
currentElement = [nodes objectAtIndex: count];
|
||||
if ([currentElement nodeType] == DOM_ELEMENT_NODE
|
||||
&& [[currentElement tagName] isEqualToString: tagName]
|
||||
&& (!namespace
|
||||
|| [[currentNode nodeName] isEqualToString: namespace]))
|
||||
[childNodesWithTag addObject: currentNode];
|
||||
|| [[currentElement namespaceURI] isEqualToString: namespace]))
|
||||
[childElementsWithTag addObject: currentElement];
|
||||
}
|
||||
|
||||
return childNodesWithTag;
|
||||
return childElementsWithTag;
|
||||
}
|
||||
|
||||
- (id <DOMNodeList>) childNodesWithTag: (NSString *) tagName
|
||||
- (id <DOMNodeList>) childElementsWithTag: (NSString *) tagName
|
||||
{
|
||||
return [self childNodesWithTag: tagName inNamespace: nil];
|
||||
return [self childElementsWithTag: tagName inNamespace: nil];
|
||||
}
|
||||
|
||||
- (id <NSObject, DOMNode>) firstNodeWithTag: (NSString *) tagName
|
||||
inNamespace: (NSString *) namespace
|
||||
- (id <DOMElement>) firstElementWithTag: (NSString *) tagName
|
||||
inNamespace: (NSString *) namespace
|
||||
{
|
||||
id <DOMNodeList> nodes;
|
||||
id <NSObject, DOMNode> node, currentNode;
|
||||
id <DOMElement> node, currentElement;
|
||||
unsigned int count, max;
|
||||
|
||||
node = nil;
|
||||
@@ -71,20 +72,20 @@
|
||||
max = [nodes length];
|
||||
for (count = 0; !node && count < max; count++)
|
||||
{
|
||||
currentNode = [nodes objectAtIndex: count];
|
||||
if ([[currentNode nodeName] isEqualToString: tagName]
|
||||
currentElement = [nodes objectAtIndex: count];
|
||||
if ([currentElement nodeType] == DOM_ELEMENT_NODE
|
||||
&& [[currentElement tagName] isEqualToString: tagName]
|
||||
&& (!namespace
|
||||
|| [[currentNode nodeName] isEqualToString: namespace]))
|
||||
node = currentNode;
|
||||
|| [[currentElement namespaceURI] isEqualToString: namespace]))
|
||||
node = currentElement;
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
- (id<NSObject,DOMNode>) firstNodeWithTag: (NSString *) tagName
|
||||
- (id <DOMElement>) firstElementWithTag: (NSString *) tagName
|
||||
{
|
||||
return [self firstNodeWithTag: tagName inNamespace: nil];
|
||||
return [self firstElementWithTag: tagName inNamespace: nil];
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user