00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #define MAX_ELEMENTS 100
00035 #define MAX_ATTRIBUTES 100
00036
00037 #define TBXML_ATTRIBUTE_NAME_START 0
00038 #define TBXML_ATTRIBUTE_NAME_END 1
00039 #define TBXML_ATTRIBUTE_VALUE_START 2
00040 #define TBXML_ATTRIBUTE_VALUE_END 3
00041 #define TBXML_ATTRIBUTE_CDATA_END 4
00042
00043
00044
00045
00046 typedef struct _TBXMLAttribute {
00047 char * name;
00048 char * value;
00049 struct _TBXMLAttribute * next;
00050 } TBXMLAttribute;
00051
00052 typedef struct _TBXMLElement {
00053 char * name;
00054 char * text;
00055
00056 TBXMLAttribute * firstAttribute;
00057
00058 struct _TBXMLElement * parentElement;
00059
00060 struct _TBXMLElement * firstChild;
00061 struct _TBXMLElement * currentChild;
00062
00063 struct _TBXMLElement * nextSibling;
00064 struct _TBXMLElement * previousSibling;
00065
00066 } TBXMLElement;
00067
00068 typedef struct _TBXMLElementBuffer {
00069 TBXMLElement * elements;
00070 struct _TBXMLElementBuffer * next;
00071 struct _TBXMLElementBuffer * previous;
00072 } TBXMLElementBuffer;
00073
00074 typedef struct _TBXMLAttributeBuffer {
00075 TBXMLAttribute * attributes;
00076 struct _TBXMLAttributeBuffer * next;
00077 struct _TBXMLAttributeBuffer * previous;
00078 } TBXMLAttributeBuffer;
00079
00080
00081
00082
00083 @interface TBXML : NSObject {
00084
00085 @private
00086 TBXMLElement * rootXMLElement;
00087
00088 TBXMLElementBuffer * currentElementBuffer;
00089 TBXMLAttributeBuffer * currentAttributeBuffer;
00090
00091 long currentElement;
00092 long currentAttribute;
00093
00094 char * bytes;
00095 long bytesLength;
00096 }
00097
00098 @property (nonatomic, readonly) TBXMLElement * rootXMLElement;
00099
00100 + (id)tbxmlWithURL:(NSURL*)aURL;
00101 + (id)tbxmlWithXMLString:(NSString*)aXMLString;
00102 + (id)tbxmlWithXMLData:(NSData*)aData;
00103 + (id)tbxmlWithXMLFile:(NSString*)aXMLFile;
00104 + (id)tbxmlWithXMLFile:(NSString*)aXMLFile fileExtension:(NSString*)aFileExtension;
00105
00106 - (id)initWithURL:(NSURL*)aURL;
00107 - (id)initWithXMLString:(NSString*)aXMLString;
00108 - (id)initWithXMLData:(NSData*)aData;
00109 - (id)initWithXMLFile:(NSString*)aXMLFile;
00110 - (id)initWithXMLFile:(NSString*)aXMLFile fileExtension:(NSString*)aFileExtension;
00111
00112 @end
00113
00114
00115
00116
00117
00118 @interface TBXML (StaticFunctions)
00119
00120 + (NSString*) elementName:(TBXMLElement*)aXMLElement;
00121 + (NSString*) textForElement:(TBXMLElement*)aXMLElement;
00122 + (NSString*) valueOfAttributeNamed:(NSString *)aName forElement:(TBXMLElement*)aXMLElement;
00123
00124 + (NSString*) attributeName:(TBXMLAttribute*)aXMLAttribute;
00125 + (NSString*) attributeValue:(TBXMLAttribute*)aXMLAttribute;
00126
00127 + (TBXMLElement*) nextSiblingNamed:(NSString*)aName searchFromElement:(TBXMLElement*)aXMLElement;
00128 + (TBXMLElement*) childElementNamed:(NSString*)aName parentElement:(TBXMLElement*)aParentXMLElement;
00129
00130 @end