Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Cleaned up header

  • Loading branch information...
commit c0c9b95e970f5f75280c0eb5f6e34e8742ebd606 1 parent f20f580
Ben Reeves authored
Showing with 27 additions and 16 deletions.
  1. +27 −16 HTMLNode.h
View
43 HTMLNode.h
@@ -35,24 +35,30 @@ typedef enum
@interface HTMLNode : NSObject
{
- @public
-
+@public
xmlNode * _node;
}
-//Init with a lib xml node
+//Init with a lib xml node (shouldn't need to be called manually)
+//Use [parser doc] to get the root Node
-(id)initWithXMLNode:(xmlNode*)xmlNode;
--(NSArray*)findChildrenOfClass:(NSString*)className;
+//Returns a single child of class
-(HTMLNode*)findChildOfClass:(NSString*)className;
--(NSArray*)findChildrenWithAttribute:(NSString*)attribute matchingName:(NSString*)className allowPartial:(BOOL)partial;
+//Returns all children of class
+-(NSArray*)findChildrenOfClass:(NSString*)className;
+
+//Finds a single child with a matching attribute
+//set allowPartial to match partial matches
+//e.g. <img src="http://www.google.com> [findChildWithAttribute:@"src" matchingName:"google.com" allowPartial:TRUE]
-(HTMLNode*)findChildWithAttribute:(NSString*)attribute matchingName:(NSString*)className allowPartial:(BOOL)partial;
+//Finds all children with a matching attribute
+-(NSArray*)findChildrenWithAttribute:(NSString*)attribute matchingName:(NSString*)className allowPartial:(BOOL)partial;
+
//Gets the attribute value matching tha name
-(NSString*)getAttributeNamed:(NSString*)name;
-NSString * getAttributeNamed(xmlNode * node, const char * nameStr);
-void setAttributeNamed(xmlNode * node, const char * nameStr, const char * value);
//Find childer with the specified tag name
-(NSArray*)findChildTags:(NSString*)tagName;
@@ -63,10 +69,14 @@ void setAttributeNamed(xmlNode * node, const char * nameStr, const char * value)
//Returns the first child element
-(HTMLNode*)firstChild;
-//Contents of this node and children
+//Returns the plaintext contents of node
+-(NSString*)contents;
+
+//Returns the plaintext contents of this node + all children
-(NSString*)allContents;
-NSString * allNodeContents(xmlNode*node);
+//Returns the html contents of the node
+-(NSString*)rawContents;
//Returns next sibling in tree
-(HTMLNode*)nextSibling;
@@ -74,9 +84,6 @@ NSString * allNodeContents(xmlNode*node);
//Returns previous sibling in tree
-(HTMLNode*)previousSibling;
-//Returns the contents
--(NSString*)contents;
-
//Returns the class name
-(NSString*)className;
@@ -86,15 +93,19 @@ NSString * allNodeContents(xmlNode*node);
//Returns the parent
-(HTMLNode*)parent;
-//Returns the contents including html tags
--(NSString*)rawContents;
-NSString * rawContentsOfNode(xmlNode * node);
-
//Returns the first level of children
-(NSArray*)children;
//Returns the node type if know
-(HTMLNodeType)nodetype;
+
+
+//C functions for minor performance increase in tight loops
+NSString * getAttributeNamed(xmlNode * node, const char * nameStr);
+void setAttributeNamed(xmlNode * node, const char * nameStr, const char * value);
HTMLNodeType nodeType(xmlNode* node);
+NSString * allNodeContents(xmlNode*node);
+NSString * rawContentsOfNode(xmlNode * node);
+
@end
Please sign in to comment.
Something went wrong with that request. Please try again.