Up

# NSXMLElement class documentation

### Authors

Richard Frith-Macdonald (`rfm@gnu.org`)

Date: Generated at 2025-02-13 06:02:40 +0000

Copyright: (C) 2008 Free Software Foundation, Inc.

# Software documentation for the NSXMLElement class

## NSXMLElement : NSXMLNode

> Declared in:
>   Foundation/NSXMLElement.h

Availability: OpenStep
Represents an XML element.
Method summary

- -addAttribute:
- -addChild:
- -addNamespace:
- -attributeForLocalName:URI:
- -attributeForName:
- -attributes
- -elementsForLocalName:URI:
- -elementsForName:
- -initWithName:
- -initWithName:URI:
- -initWithName:stringValue:
- -initWithXMLString:error:
- -insertChild:atIndex:
- -insertChildren:atIndex:
- -namespaceForPrefix:
- -namespaces
- -normalizeAdjacentTextNodesPreservingCDATA:
- -removeAttributeForName:
- -removeChildAtIndex:
- -removeNamespaceForPrefix:
- -replaceChildAtIndex:withNode:
- -resolveNamespaceForName:
- -resolvePrefixForNamespaceURI:
- -setAttributes:
- -setAttributesAsDictionary:
- -setAttributesWithDictionary:
- -setChildren:
- -setNamespaces:

### addAttribute:

- (void) addAttribute: (NSXMLNode*)attribute;
Availability: OpenStep
Adds the supplied attribute to the receiver (ignoring if it has a duplicate name).

### addChild:

- (void) addChild: (NSXMLNode*)child;
Availability: OpenStep
Adds a child after existing children.

### addNamespace:

- (void) addNamespace: (NSXMLNode*)aNamespace;
Availability: OpenStep
Adds a namespace unless the name is a duplicate.

### attributeForLocalName: URI:

- (NSXMLNode*) attributeForLocalName: (NSString*)localName URI: (NSString*)URI;
Availability: OpenStep
Returns the attribute matching localName and URI.

### attributeForName:

- (NSXMLNode*) attributeForName: (NSString*)name;
Availability: OpenStep
Returns the named attribute.

### attributes

- (NSArray*) attributes;
Availability: OpenStep
Returns the receiver's attributes.

### elementsForLocalName: URI:

- (NSArray*) elementsForLocalName: (NSString*)localName URI: (NSString*)URI;
Availability: OpenStep
Searches for and returns all child elements which match localName and the specified URI.

### elementsForName:

- (NSArray*) elementsForName: (NSString*)name;
Availability: OpenStep
Searches for and returns all child elements which match name.

### initWithName:

- (id) initWithName: (NSString*)name;
Availability: OpenStep
Initialises the receiver with the given name.

### initWithName: URI:

- (id) initWithName: (NSString*)name URI: (NSString*)URI;
Availability: OpenStep
Initialises the receiver with the given name and namespace URI.

### initWithName: stringValue:

- (id) initWithName: (NSString*)name stringValue: (NSString*)string;
Availability: OpenStep
Initialises the receiver as a text node with the given name and content.

### initWithXMLString: error:

- (id) initWithXMLString: (NSString*)string error: (NSError**)error;
Availability: OpenStep
Initialises the receiver by parsing the XML string supplied.

### insertChild: atIndex:

- (void) insertChild: (NSXMLNode*)child atIndex: (NSUInteger)index;
Availability: OpenStep
Inerts a child node.

### insertChildren: atIndex:

- (void) insertChildren: (NSArray*)children atIndex: (NSUInteger)index;
Availability: OpenStep
Inserts a number of children.

### namespaceForPrefix:

- (NSXMLNode*) namespaceForPrefix: (NSString*)name;
Availability: OpenStep
Returns the namespace for the specified prefix in the receiver.

### namespaces

- (NSArray*) namespaces;
Availability: OpenStep
Returns the namespaces of the receiver.

### normalizeAdjacentTextNodesPreservingCDATA:

- (void) normalizeAdjacentTextNodesPreservingCDATA: (BOOL)preserve;
Availability: OpenStep
Merges adjacent text nodes. If a node's value is the empty string, and preserve is `NO`, it is removed.
This should be called with a value of `NO` before using XQuery or XPath.

### removeAttributeForName:

- (void) removeAttributeForName: (NSString*)name;
Availability: OpenStep
Removes the named attribute.

### removeChildAtIndex:

- (void) removeChildAtIndex: (NSUInteger)index;
Availability: OpenStep
Removes a child node.

### removeNamespaceForPrefix:

- (void) removeNamespaceForPrefix: (NSString*)name;
Availability: OpenStep
Removes a named namespace.

### replaceChildAtIndex: withNode:

- (void) replaceChildAtIndex: (NSUInteger)index withNode: (NSXMLNode*)theNode;
Availability: OpenStep
Replaces the child at the specified index.

### resolveNamespaceForName:

- (NSXMLNode*) resolveNamespaceForName: (NSString*)name;
Availability: OpenStep
Returns the namespace found by searching the chain of namespaces.

### resolvePrefixForNamespaceURI:

- (NSString*) resolvePrefixForNamespaceURI: (NSString*)namespaceURI;
Availability: OpenStep
Returns the URI by searching the chain of namespaces.

### setAttributes:

- (void) setAttributes: (NSArray*)attributes;
Availability: OpenStep
Sets the attributes of the receiver, ignoring all but the first of any duplicates.

### setAttributesAsDictionary:

- (void) setAttributesAsDictionary: (NSDictionary*)attributes;
Availability: OpenStep
Sets attributes from the supplied dictionary.
DEPRECATED... use -setAttributesWithDictionary: instead.

### setAttributesWithDictionary:

- (void) setAttributesWithDictionary: (NSDictionary*)attributes;
Availability: MacOS-X 10.7.0
Sets attributes from the supplied dictionary.

### setChildren:

- (void) setChildren: (NSArray*)children;
Availability: OpenStep
Replaces all existing child nodes with those from the array.

### setNamespaces:

- (void) setNamespaces: (NSArray*)namespaces;
Availability: OpenStep
Sets the namespaces for the receiver, ignoring all but the first of any duplicates.

Up