Adun  0.83
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Public Member Functions | Static Public Member Functions
XMLNode Class Reference

#import <XMLNode.h>

Inheritance diagram for XMLNode:
Inheritance graph
[legend]

List of all members.

Public Member Functions

(id) - initWithName:children:attributes:
(int) - index
(int) - level
(NSString *) - name
(NSString *) - fieldValue
(id) - childAtIndex:
(int) - childCount
(NSArray *) - children
(id) - nextNode
(id) - nextSibling
(id) - parent
(id) - previousNode
(id) - previousSibling
(void) - detach
(NSDictionary *) - attributes
(void) - setParent:
(void) - setName:
(void) - setAttributes:
(void) - addChild:
(void) - setIndex:
(void) - setLevel:
(void) - parser:didStartElement:namespaceURI:qualifiedName:attributes:
(void) - parser:didEndElement:namespaceURI:qualifiedName:
(void) - parser:foundCharacters:

Static Public Member Functions

(id) + nodeForElementName:children:attributes:
(id) + elementWithName:children:attributes:

Detailed Description

An instance of XMLNode represents a node in an XML file.


Member Function Documentation

- (void) addChild: (id)  child

Adds a child to the reciever

- (NSDictionary*) attributes

Returns the recievers attributes

- (id) childAtIndex: (int)  childNo

Returns the child node of the receiver at the specified index. If the receiver has no children, this method returns nil. If index is out of bounds, an exception is raised.

- (int) childCount

Returns the number of child nodes the receiver has. For performance reasons, use this method instead of getting the count from the array returned by children (for example, [[thisNode children] count]).

Note:
cache the number of childre
- (NSArray*) children

Returns an immutable array containing the child nodes of the receiver.

- (void) detach

Detaches the receiver from its parent node. Once the node object is detached, you can add it as a child node of another parent. Not Implemented **

+ (id) elementWithName: (NSString*)  elementName
children: (NSMutableArray*)  children
attributes: (NSDictionary*)  attributes 

Returns an XMLNode object with the specified tag name, attributes, and children. Specify nil in the children and attributes parameters if there are no attributes or children to add to this node object.

Parameters:
elementNameThe name of the XML element
chidrenAn NSMutableArray of child nodes (each of whoms parents must be this node)
attributesAn NSDictionary containing node attributes
Returns:
An initialised XMLNode instance
- (NSString*) fieldValue

Returns the recievers fieldValue or nil if it has none

- (int) index

Returns the index of this node which identifies its poistion relative to its siblings. The first child has an index of 0

- (id) initWithName: (NSString*)  name
children: (NSArray*)  anArray
attributes: (NSDictionary*)  attr 

Designated initialiser

- (int) level

Returns the nesting level of the receiver within the tree hierarchy. The root element of a document has a nesting level of one.

- (NSString*) name

Returns the XML element name of the receiver i.e. the element type

- (id) nextNode

Returns the next XMLNode object in document order. You use this method to walk forward through the tree structure representing an XML document or document section. (Use previousNode to traverse the tree in the opposite direction.) Document order is the natural order that XML constructs appear in markup text. If you send this message to the last node in the tree, nil is returned. XMLNode bypasses namespace and attribute nodes when it traverses a tree in document order.

- (id) nextSibling

Returns the next XMLNode object that is a sibling node to the receiver. This object will have an index value that is one more than the receiver’s. If there are no more subsequent siblings (that is, other child nodes of the receiver’s parent) the method returns nil.

+ (id) nodeForElementName: (NSString*)  elementName
children: (NSArray*)  childArray
attributes: (NSDictionary*)  attributeDict 

Returns a new initialised node for elementName. XMLNode instances use this method to create their children. In this case it returns a new XMLNode instance. Subclasses of XMLNode can override this method so when they create their children something other than an XMLNode instance will be returned. This method avoids having to directly name a class when creating a new child.

Reimplemented in FFParameterFileElement, and FFTopologyFileElement.

- (id) parent

Returns the parent node of the receiver. Document nodes and standalone nodes (that is, the root of a detached branch of a tree) have no parent, and sending this message to them returns nil. A one-to-one relationship does not always exists between a parent and its children; although a namespace or attribute node cannot be a child, it still has a parent element.

- (void) parser: (id)  parser
didEndElement: (NSString *)  elementName
namespaceURI: (NSString *)  namespaceURI
qualifiedName: (NSString *)  qName 

Delegate method for NSXMLParser. When NSXML parser encounters the end of an XML tag it sends this message to whoever is its delegate at the time.

Parameters:
parserThe NSXML parser instance that sent the message
elementNameThe name of the element whose end tag was encountered
namespaceURIthe namespaceURI of this element (not implemented)
qNameThe full path name of the element (I think. Also not implemented)
- (void) parser: (id)  parser
didStartElement: (NSString *)  elementName
namespaceURI: (NSString *)  namespaceURI
qualifiedName: (NSString *)  qualifiedName
attributes: (NSDictionary *)  attributeDict 

Delegate method for NSXMLParser. When NSXML parser encounters the start of an XML tag it sends this message to whoever is its delegate at the time.

Parameters:
parserThe NSXML parser instance that sent the message
elementNameThe name of the element whose start tag was encountered
namespaceURIthe namespaceURI of this element (not implemented)
qualifiedNameThe full path name of the element (I think. Also not implemented)
attributeDictThe attributes of the tag
- (void) parser: (NSXMLParser *)  parser
foundCharacters: (NSString *)  string 

Delegate method for NSXMLParser. When NSXML parser encounters any CDATA it sends this message to whoever is its delegate at the time.

Parameters:
parserThe NSXML parser instance that sent the message
stringA string containing the characters that were found.
- (id) previousNode

Returns the previous XMLNode object in document order. You use this method to walk backward through the tree structure representing an XML document or document section. (Use nextNode to traverse the tree in the opposite direction.) Document order is the natural order that XML constructs appear in markup text. If you send this message to the first node in the tree (that is, the root element), nil is returned. Not Implemented **

- (id) previousSibling

Returns the previous NSXMLNode object that is a sibling node to the receiver. This object will have an index value that is one less than the receivers. If there are no more previous siblings (that is, other child nodes of the receiver’s parent) the method returns nil Not Implemented **

- (void) setAttributes: (NSDictionary*)  aDict

Sets the attribtues

- (void) setIndex: (int)  childIndex

Sets the index of the receiver

- (void) setLevel: (int)  nestingLevel

Set the level of the receiver

- (void) setName: (NSString*)  nodeName

Sets the name

- (void) setParent: (id)  par

Sets the parenet