Mac Developer Library

Developer

Foundation Framework Reference NSXMLNode Class Reference

Options
Deployment Target:

On This Page
Language:

NSXMLNode

Conforms To


Import Statement


Swift

import Foundation

Objective-C

@import Foundation;

Availability


Available in OS X v10.4 and later.

Objects of the NSXMLNode class are nodes in the abstract, logical tree structure that represents an XML document. Node objects can be of different kinds, corresponding to the following markup constructs in an XML document: element, attribute, text, processing instruction, namespace, and comment. In addition, a document-node object (specifically, an instance of NSXMLDocument) represents an XML document in its entirety. NSXMLNode objects can also represent document type declarations as well as declarations in Document Type Definitions (DTDs). Class factory methods of NSXMLNode enable you to create nodes of each kind. Only document, element, and DTD nodes may have child nodes.

Among the NSXML family of classes—that is, the Foundation classes with the prefix “NSXML” (excluding NSXMLParser)—the NSXMLNode class is the base class. Inheriting from it are the classes NSXMLElement, NSXMLDocument, NSXMLDTD, and NSXMLDTDNode. NSXMLNode specifies the interface common to all XML node objects and defines common node behavior and attributes, for example hierarchy level, node name and value, tree traversal, and the ability to emit representative XML markup text.

Subclassing Notes

You can subclass NSXMLNode if you want nodes of kinds different from the supported ones, You can also create a subclass with more specialized attributes or behavior than NSXMLNode.

Methods to Override

To subclass NSXMLNode you need to override the primary initializer, initWithKind:options:, and the methods listed below. In most cases, you need only invoke the superclass implementation, adding any subclass-specific code before or after the invocation, as necessary.

By default NSXMLNode implements the NSObject isEqual: method to perform a deep comparison: two NSXMLNode objects are not considered equal unless they have the same name, same child nodes, same attributes, and so on. The comparison looks at the node and its children, but does not include the node’s parent. If you want a different standard of comparison, override isEqual:.

Special Considerations

Because of the architecture and data model of NSXML, when it parses and processes a source of XML it cannot know about your subclass unless you override the NSXMLDocument class method replacementClassForClass: to return your custom class in place of an NSXML class. If your custom class has no direct NSXML counterpart—for example, it is a subclass of NSXMLNode that represents CDATA sections—then you can walk the tree after it has been created and insert the new node where appropriate.

  • Returns an NSXMLNode instance initialized with the constant indicating node kind.

    Declaration

    Swift

    convenience init(kind kind: NSXMLNodeKind)

    Objective-C

    - (instancetype)initWithKind:(NSXMLNodeKind)kind

    Parameters

    kind

    An enum constant of type Node Kind Constants that indicates the type of node. See Constants for a list of valid NSXMLNodeKind constants.

    Return Value

    An NSXMLNode object initialized with kind or nil if the object couldn't be created. If kind is not a valid NSXMLNodeKind constant, the method returns an NSXMLNode object of kind NSXMLInvalidKind.

    Discussion

    This method invokes initWithKind:options: with the options parameter set to NSXMLNodeOptionsNone.

    Do not use this initializer for creating instances of NSXMLDTDNode for attribute-list declarations. Instead, use the DTDNodeWithXMLString: class method of this class or the initWithXMLString: method of the NSXMLDTDNode class.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.4 and later.

  • Returns an NSXMLNode instance initialized with the constant indicating node kind and one or more initialization options.

    Declaration

    Swift

    init(kind kind: NSXMLNodeKind, options options: Int)

    Objective-C

    - (instancetype)initWithKind:(NSXMLNodeKind)kind options:(NSUInteger)options

    Parameters

    kind

    An enum constant of type Node Kind Constants that indicates the type of node. See Constants for a list of valid NSXMLNodeKind constants.

    options

    One or more constants that specify initialization options; if there are multiple constants, bit-OR them together. These options request operations on the represented XML related to fidelity (for example, preserving entities), quoting style, handling of empty elements, and other things. See Constants for a list of valid node-initialization constants.

    Return Value

    An NSXMLNode object initialized with the given kind and options, or nil if the object couldn't be created. If kind is not a valid NSXMLNodeKind constant, the method returns an NSXMLNode object of kind NSXMLInvalidKind.

    Discussion

    Do not use this initializer for creating instances of NSXMLDTDNode for attribute-list declarations. Instead, use the DTDNodeWithXMLString: class method of this class or the initWithXMLString: method of the NSXMLDTDNode class.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.4 and later.

  • Returns an empty document node.

    Declaration

    Swift

    class func document() -> AnyObject?

    Objective-C

    + (id)document

    Return Value

    An empty document node—that is, an NSXMLDocument instance without a root element or XML-declaration information (version, encoding, standalone flag). Returns nil if the object couldn't be created.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.4 and later.

  • Returns an NSXMLDocument object initialized with a given root element.

    Declaration

    Swift

    class func documentWithRootElement(_ element: NSXMLElement!) -> AnyObject?

    Objective-C

    + (id)documentWithRootElement:(NSXMLElement *)element

    Parameters

    element

    An NSXMLElement object representing an element.

    Return Value

    An NSXMLDocument object initialized with the root element element or nil if the object couldn't be created.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.4 and later.

  • Returns an NSXMLElement object with a given tag identifier, or name

    Declaration

    Swift

    class func elementWithName(_ name: String) -> AnyObject?

    Objective-C

    + (id)elementWithName:(NSString *)name

    Parameters

    name

    A string that is the name (or tag identifier) of an element.

    Return Value

    An NSXMLElement object or nil if the object couldn't be created.

    Discussion

    The equivalent XML markup is <name></name>.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.4 and later.

  • Returns an NSXMLElement object with the given tag (name), attributes, and children.

    Declaration

    Swift

    class func elementWithName(_ name: String!, children children: [AnyObject]?, attributes attributes: [AnyObject]?) -> AnyObject?

    Objective-C

    + (id)elementWithName:(NSString *)name children:(NSArray *)children attributes:(NSArray *)attributes

    Parameters

    name

    A string that is the name (tag identifier) of the element.

    children

    An array of NSXMLElement objects or NSXMLNode objects of kinds NSXMLElementKind, NSXMLProcessingInstructionKind, NSXMLCommentKind, and NSXMLTextKind. Specify nil if there are no children to add to this node object.

    attributes

    An array of NSXMLNode objects of kind NSXMLAttributeKind. Specify nil if there are no attributes to add to this node object.

    Return Value

    An NSXMLElement object or nil if the object couldn't be created.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.4 and later.

  • Returns an NSXMLElement object with a single text-node child containing the specified text.

    Declaration

    Swift

    class func elementWithName(_ name: String!, stringValue string: String!) -> AnyObject?

    Objective-C

    + (id)elementWithName:(NSString *)name stringValue:(NSString *)string

    Parameters

    name

    A string that is the name (tag identifier) of the element.

    string

    A string that is the content of the receiver's text node.

    Return Value

    An NSXMLElement object with a single text-node child—an NSXMLNode object of kind NSXMLTextKind—containing the text specified in string. Returns nil if the object couldn't be created.

    Discussion

    The equivalent XML markup is <name>string</name>.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.4 and later.

  • Returns an element whose fully qualified name is specified.

    Declaration

    Swift

    class func elementWithName(_ name: String!, URI URI: String!) -> AnyObject?

    Objective-C

    + (id)elementWithName:(NSString *)name URI:(NSString *)URI

    Parameters

    name

    A string that is the name (or tag identifier) of an element.

    URI

    A URI (Universal Resource Identifier) that qualifies name.

    Return Value

    An NSXMLElement object or nil if the object cannot be created.

    Discussion

    The equivalent XML markup is <URI:name></URI:name>.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.4 and later.

  • Returns an NSXMLNode object representing an attribute node with a given name and string.

    Declaration

    Swift

    class func attributeWithName(_ name: String, stringValue value: String) -> AnyObject?

    Objective-C

    + (id)attributeWithName:(NSString *)name stringValue:(NSString *)value

    Parameters

    name

    A string that is the name of an attribute.

    value

    A string that is the value of an attribute.

    Return Value

    An NSXMLNode object of kind NSXMLAttributeKind or nil if the object couldn't be created.

    Discussion

    For example, in the attribute “id=`12345’”, “id” is the attribute name and “12345” is the attribute value.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.4 and later.

  • Returns an NSXMLNode object representing an attribute node with a given qualified name and string.

    Declaration

    Swift

    class func attributeWithName(_ name: String!, URI URI: String!, stringValue value: String!) -> AnyObject?

    Objective-C

    + (id)attributeWithName:(NSString *)name URI:(NSString *)URI stringValue:(NSString *)value

    Parameters

    name

    A string that is the name of an attribute.

    URI

    A URI (Universal Resource Identifier) that qualifies name.

    value

    A string that is the value of the attribute.

    Return Value

    An NSXMLNode object of kind NSXMLAttributeKind or nil if the object couldn't be created.

    Discussion

    For example, in the attribute “bst:id=`12345’”, “bst” is the name qualifier (derived from the URI), “id” is the attribute name, and “12345” is the attribute value.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.4 and later.

  • Returns an NSXMLNode object representing a text node with specified content.

    Declaration

    Swift

    class func textWithStringValue(_ value: String!) -> AnyObject?

    Objective-C

    + (id)textWithStringValue:(NSString *)value

    Parameters

    value

    A string that is the textual content of the node.

    Return Value

    An NSXMLNode object of kind NSXMLTextKind initialized with the textual value or nil if the object couldn't be created.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.4 and later.

  • Returns an NSXMLNode object representing an comment node containing given text.

    Declaration

    Swift

    class func commentWithStringValue(_ stringValue: String!) -> AnyObject?

    Objective-C

    + (id)commentWithStringValue:(NSString *)stringValue

    Parameters

    stringValue

    A string specifying the text of the comment. You may specify nil or an empty string (see Return Value).

    Return Value

    An NSXMLNode object representing an comment node (NSXMLCommentKind) containing the text stringValue or nil if the object couldn't be created. If stringValue is nil or an empty string, a content-less comment node is returned (<!--->).

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.4 and later.

  • Returns an NSXMLNode object representing a namespace with a specified name and URI.

    Declaration

    Swift

    class func namespaceWithName(_ name: String, stringValue value: String) -> AnyObject?

    Objective-C

    + (id)namespaceWithName:(NSString *)name stringValue:(NSString *)value

    Parameters

    name

    A string that is the name of the namespace. Specify an empty string for name to get the default namespace.

    value

    A string that identifies the URI associated with the namespace.

    Return Value

    An NSXMLNode object of kind NSXMLNamespaceKind or nil if the object couldn't be created.

    Discussion

    The equivalent namespace declaration in XML markup is xmlns:name="value".

    Special Considerations

    Applications linked on OS X v10.6 or later will throw an exception if the name parameter is nil.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.4 and later.

  • Returns a NSXMLDTDNode object representing the DTD declaration for an element, attribute, entity, or notation based on a given string.

    Declaration

    Swift

    class func DTDNodeWithXMLString(_ string: String) -> AnyObject?

    Objective-C

    + (id)DTDNodeWithXMLString:(NSString *)string

    Parameters

    string

    A string that is a DTD declaration. The receiver parses this string to determine the kind of DTD node to create.

    Return Value

    An NSXMLDTDNode object representing the DTD declaration or nil if the object couldn't be created.

    Discussion

    For example, if string is the following:

    • <!ENTITY name (#PCDATA)>

    NSXMLNode is able to assign the created node object a kind of NSXMLEntityDeclarationKind by parsing “ENTITY”.

    Note that if an attribute-list declaration (<!ATTLIST...> )has multiple attributes NSXMLNode only creates an NSXMLDTDNode object for the last attribute in the declaration.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.4 and later.

  • Returns an NSXMLNode object representing one of the predefined namespaces with the specified prefix.

    Declaration

    Swift

    class func predefinedNamespaceForPrefix(_ name: String) -> NSXMLNode?

    Objective-C

    + (NSXMLNode *)predefinedNamespaceForPrefix:(NSString *)name

    Parameters

    name

    A string specifying a prefix for a predefined namespace, for example “xml”, “xs”, or “xsi”.

    Return Value

    An NSXMLNode object of kind NSXMLNamespaceKind or nil if the object couldn't be created. If something other than a predefined-namespace prefix is specified, the method returns nil.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.4 and later.

  • Returns an NSXMLNode object representing a processing instruction with a specified name and value.

    Declaration

    Swift

    class func processingInstructionWithName(_ name: String, stringValue value: String) -> AnyObject?

    Objective-C

    + (id)processingInstructionWithName:(NSString *)name stringValue:(NSString *)value

    Parameters

    name

    A string that is the name of the processing instruction.

    value

    A string that is the value of the processing instruction.

    Return Value

    An NSXMLNode object of kind NSXMLProcessingInstructionKind or nil if the object couldn't be created.

    Discussion

    The equivalent XML markup is <?name value?>.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.4 and later.

  • Returns the index of the receiver identifying its position relative to its sibling nodes.

    Declaration

    Swift

    var index: Int { get }

    Objective-C

    @property(readonly) NSUInteger index

    Return Value

    An integer that is the index of the receiver relative to its sibling nodes.

    Discussion

    The first child node of a parent has an index of zero.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.4 and later.

  • Returns the kind of node the receiver is as a constant of type Node Kind Constants.

    Declaration

    Swift

    var kind: NSXMLNodeKind { get }

    Objective-C

    @property(readonly) NSXMLNodeKind kind

    Discussion

    NSXMLNode objects can represent documents, elements, attributes, namespaces, text, processing instructions, comments, document type declarations, and specific declarations within DTDs. See Constants for a list of valid NSXMLNodeKind constants

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.4 and later.

  • Returns the nesting level of the receiver within the tree hierarchy.

    Declaration

    Swift

    var level: Int { get }

    Objective-C

    @property(readonly) NSUInteger level

    Return Value

    An integer indicating a nesting level.

    Discussion

    The root element of a document has a nesting level of one.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.4 and later.

  • Sets the name of the receiver.

    Declaration

    Swift

    var name: String?

    Objective-C

    @property(copy) NSString *name

    Parameters

    name

    A string that is the name to assign to the receiver.

    Discussion

    This method is effective for the following node kinds: element, attribute, namespace, processing-instruction, document type declaration, element declaration, attribute declaration, entity declaration, and notation declaration. If an NSXMLNode object that requires a name doesn’t have one, it cannot be written out as an XML string.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.4 and later.

    See Also

    – name

  • Returns the name of the receiver.

    Declaration

    Swift

    var name: String?

    Objective-C

    @property(copy) NSString *name

    Return Value

    Returns a string specifying the name of the receiver. May return nil if the receiver is not a valid kind of node (see discussion).

    Discussion

    This method is applicable only to NSXMLNode objects representing elements, attributes, namespaces, processing instructions, and DTD-declaration nodes. If the receiver is not an object of one of these kinds, this method returns nil. For example, in the following construction:

    • <title>Chapter One</title>

    The returned name for the element is “title”. If the name is associated with a namespace, the qualified name is returned. For example, if you create an element with local name “foo” and URI “http://bar.com” and the namespace “xmlns:baz=‘http://bar.com’” is applied to this node, when you invoke this method on the node you get “baz:foo”.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.4 and later.

    See Also

    – setName:

  • Sets the content of the receiver to an object value.

    Declaration

    Swift

    var objectValue: AnyObject?

    Objective-C

    @property(retain) id objectValue

    Parameters

    value

    An object to assign as the value to the receiver.

    Discussion

    This method can only be invoked on NSXMLNode objects that may have content, specifically elements, attributes, namespaces, processing instructions, text, and DTD-declaration nodes. The given object is usually a Foundation equivalent to one of the atomic types in the XQuery data model: NSNumber (integer, decimal, float, double, Boolean), NSString (string), NSCalendarDate (date), NSData (base64Binary and hexBinary), NSURL (URI), and NSArray (NMTOKENS, IDREFS, ENTITIES). However, you can also set the object value to be a custom value and register a value transformer (that is, an instance of NSValueTransformer) to convert the object value to an XML string representation when the node is asked for its string value.

    Setting a node’s object value removes all existing children, including processing instructions and comments. Setting an element node’s object value creates a text node as the sole child. When an NSXMLNode object emits its object-value contents as a string, and it can determine the type of the value, it ensures that it the string is in a canonical form as defined by the W3C XML Schema Data Types specification.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.4 and later.

  • Returns the object value of the receiver.

    Declaration

    Swift

    var objectValue: AnyObject?

    Objective-C

    @property(retain) id objectValue

    Return Value

    The object value of the receiver, which may be the same as the value returned by stringValue. For nodes without content (for example, document nodes), this method returns the string value, or an empty string if there is no string value.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.4 and later.

  • Sets the content of the receiver as a string value.

    Declaration

    Swift

    var stringValue: String?

    Objective-C

    @property(copy) NSString *stringValue

    Parameters

    string

    A string to assign as the value of the receiver.

    Discussion

    This method invokes setStringValue:resolvingEntities:, passing in an argument of NOfalse for the second parameter. This method can only be invoked on NSXMLNode objects that may have content, specifically elements, attributes, namespaces, processing instructions, text, and DTD-declaration nodes. Setting the string value of a node object removes all existing children, including processing instructions and comments. Setting the string value of an element-node object creates a text node as the sole child.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.4 and later.

  • Sets the content of the receiver as a string value and, optionally, resolves character references, predefined entities, and user-defined entities as declared in the associated DTD.

    Declaration

    Swift

    func setStringValue(_ string: String, resolvingEntities resolve: Bool)

    Objective-C

    - (void)setStringValue:(NSString *)string resolvingEntities:(BOOL)resolve

    Parameters

    string

    A string to assign as the value of the receiver.

    resolve

    YEStrue to resolve character references, predefined entities, and user-defined entities as declared in the associated DTD; NOfalse otherwise. Namespace and processing-instruction nodes have their entities resolved even if resolve is NOfalse.

    Discussion

    User-defined entities not declared in the DTD remain in their unresolved form. This method can only be invoked on NSXMLNode objects that may have content, specifically elements, attributes, namespaces, processing instructions, text, and DTD-declaration nodes. Setting the string value of a node object removes all existing children, including processing instructions and comments. Setting the string value of an element -node object creates a text node as the sole child.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.4 and later.

  • Returns the content of the receiver as a string value.

    Declaration

    Swift

    var stringValue: String?

    Objective-C

    @property(copy) NSString *stringValue

    Discussion

    If the receiver is a node object of element kind, the content is that of any text-node children. This method recursively visits elements nodes and concatenates their text nodes in document order with no intervening spaces. If the receiver’s content is set as an object value, this method returns the string value representing the object. If the object value is one of the standard, built-in ones (NSNumber, NSCalendarDate, and so on), the string value is in canonical format as defined by the W3C XML Schema Data Types specification. If the object value is not represented by one of these classes (or if the default value transformer for a class has been overridden), the string value is generated by the NSValueTransformer registered for that object type.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.4 and later.

  • setURI: - setURI: Available in OS X v10.4 through OS X v10.9

    Sets the URI of the receiver.

    Declaration

    Objective-C

    - (void)setURI:(NSString *)URI

    Parameters

    URI

    The URI to associate with the receiver. A URI (Universal Resource Identifier) is a scheme such as “http” or “ftp” followed by a colon character, and then a scheme-specific part.

    Discussion

    The receiver must be an NSXMLElement or NSXMLDocument document, or an attribute (that is, anNSXMLNode object of type NSXMLAttributeKind). For documents it is the URI of document origin.

    Import Statement

    Objective-C

    @import Foundation;

    Availability

    Available in OS X v10.4 through OS X v10.9.

  • Returns the URI associated with the receiver.

    Declaration

    Swift

    var URI: String?

    Objective-C

    @property(copy) NSString *URI

    Discussion

    A node’s URI is derived from its namespace or a document’s URI; for documents, the URI comes either from the parsed XML or is explicitly set. You cannot change the URI for a particular node other for than a namespace or document node.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.4 and later.

    See Also

    setURI: (NSXMLDocument)

  • Returns the NSXMLDocument object containing the root element and representing the XML document as a whole.

    Declaration

    Swift

    var rootDocument: NSXMLDocument? { get }

    Objective-C

    @property(readonly, retain) NSXMLDocument *rootDocument

    Discussion

    If the receiver is a standalone node (that is, a node at the head of a detached branch of the tree), this method returns nil.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.4 and later.

  • Returns the parent node of the receiver.

    Declaration

    Swift

    @NSCopying var parent: NSXMLNode? { get }

    Objective-C

    @property(readonly, copy) NSXMLNode *parent

    Discussion

    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.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.4 and later.

  • Returns the child node of the receiver at the specified location.

    Declaration

    Swift

    func childAtIndex(_ index: Int) -> NSXMLNode?

    Objective-C

    - (NSXMLNode *)childAtIndex:(NSUInteger)index

    Parameters

    index

    An integer specifying a node position in the receiver's array of children. If index is out of bounds, an exception is raised.

    Return Value

    An NSXMLNode object or nil f the receiver has no children.

    Discussion

    The receiver should be an NSXMLNode object representing a document, element, or document type declaration. The returned node object can represent an element, comment, text, or processing instruction.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.4 and later.

    See Also

    – childCount

  • Returns the number of child nodes the receiver has.

    Declaration

    Swift

    var childCount: Int { get }

    Objective-C

    @property(readonly) NSUInteger childCount

    Discussion

    This receiver should be an NSXMLNode object representing a document, element, or document type declaration. For performance reasons, use this method instead of getting the count from the array returned by children (for example, [[thisNode children] count]).

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.4 and later.

  • Returns an immutable array containing the child nodes of the receiver (as NSXMLNode objects).

    Declaration

    Swift

    var children: [AnyObject]? { get }

    Objective-C

    @property(readonly, copy) NSArray *children

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.4 and later.

  • Returns the next NSXMLNode object in document order.

    Declaration

    Swift

    @NSCopying var nextNode: NSXMLNode? { get }

    Objective-C

    @property(readonly, copy) NSXMLNode *nextNode

    Discussion

    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. NSXMLNode bypasses namespace and attribute nodes when it traverses a tree in document order.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.4 and later.

  • Returns the next NSXMLNode object that is a sibling node to the receiver.

    Declaration

    Swift

    @NSCopying var nextSibling: NSXMLNode? { get }

    Objective-C

    @property(readonly, copy) NSXMLNode *nextSibling

    Discussion

    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.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.4 and later.

  • Returns the previous NSXMLNode object in document order.

    Declaration

    Swift

    @NSCopying var previousNode: NSXMLNode? { get }

    Objective-C

    @property(readonly, copy) NSXMLNode *previousNode

    Discussion

    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. NSXMLNode bypasses namespace and attribute nodes when it traverses a tree in document order.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.4 and later.

  • Returns the previous NSXMLNode object that is a sibling node to the receiver.

    Declaration

    Swift

    @NSCopying var previousSibling: NSXMLNode? { get }

    Objective-C

    @property(readonly, copy) NSXMLNode *previousSibling

    Discussion

    This object will have an index value that is one less than the receiver’s. If there are no more previous siblings (that is, other child nodes of the receiver’s parent) the method returns nil

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.4 and later.

  • Detaches the receiver from its parent node.

    Declaration

    Swift

    func detach()

    Objective-C

    - (void)detach

    Discussion

    This method is applicable to NSXMLNode objects representing elements, text, comments, processing instructions, attributes, and namespaces. Once the node object is detached, you can add it as a child node of another parent.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.4 and later.

  • Returns the string representation of the receiver as it would appear in an XML document.

    Declaration

    Swift

    var XMLString: String { get }

    Objective-C

    @property(readonly, copy) NSString *XMLString

    Discussion

    The returned string includes the string representations of all children. This method invokes XMLStringWithOptions: with an options argument of NSXMLNodeOptionsNone.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.4 and later.

  • Returns the string representation of the receiver as it would appear in an XML document, with one or more output options specified.

    Declaration

    Swift

    func XMLStringWithOptions(_ options: Int) -> String

    Objective-C

    - (NSString *)XMLStringWithOptions:(NSUInteger)options

    Parameters

    options

    One or more enum constants identifying an output option; bit-OR multiple constants together. See Constants for a list of valid constants for specifying output options.

    Discussion

    The returned string includes the string representations of all children.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.4 and later.

  • Returns a string object encapsulating the receiver’s XML in canonical form.

    Declaration

    Swift

    func canonicalXMLStringPreservingComments(_ comments: Bool) -> String

    Objective-C

    - (NSString *)canonicalXMLStringPreservingComments:(BOOL)comments

    Parameters

    comments

    YEStrue to preserve comments, NOfalse otherwise.

    Discussion

    Be sure to set the input option NSXMLNodePreserveWhitespace for true canonical form. The canonical form of an XML document is defined by the World Wide Web Consortium at http://www.w3.org/TR/xml-c14n. Generally, if two documents with varying physical representations have the same canonical form, then they are considered logically equivalent within the given application context. The following list summarizes most key aspects of canonical form as defined by the W3C recommendation:

    • Encodes the document in UTF-8.

    • Normalizes line breaks to “#xA” on input before parsing.

    • Normalizes attribute values in the manner of a validating processor.

    • Replaces character and parsed entity references with their character content.

    • Replaces CDATA sections with their character content.

    • Removes the XML declaration and the document type declaration (DTD).

    • Converts empty elements to start-end tag pairs.

    • Normalizes whitespace outside of the document element and within start and end tags.

    • Retains all whitespace characters in content (excluding characters removed during line-feed normalization).

    • Sets attribute value delimiters to quotation marks (double quotes).

    • Replaces special characters in attribute values and character content with character references.

    • Removes superfluous namespace declarations from each element.

    • Adds default attributes to each element.

    • Imposes lexicographic order on the namespace declarations and attributes of each element.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.4 and later.

  • Returns a description of the receiver.

    Declaration

    Swift

    var description: String { get }

    Objective-C

    @property(readonly, copy) NSString *description

    Discussion

    Use this method for debugging rather than for generating XML output. It could yield more information than XMLString and XMLStringWithOptions:.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.4 and later.

  • Returns the nodes resulting from executing an XPath query upon the receiver.

    Declaration

    Swift

    func nodesForXPath(_ xpath: String, error error: NSErrorPointer) -> [AnyObject]?

    Objective-C

    - (NSArray *)nodesForXPath:(NSString *)xpath error:(NSError **)error

    Parameters

    xpath

    A string that expresses an XPath query.

    error

    If query errors occur, indirectly returns an NSError object describing the errors.

    Return Value

    An array of NSXMLNode objects that match the query, or an empty array if there are no matches.

    Discussion

    The receiver acts as the context item for the query (“.”). If you have explicitly added adjacent text nodes as children of an element, you should invoke the NSXMLElement method normalizeAdjacentTextNodesPreservingCDATA: (with an argument of NOfalse) on the element before applying any XPath queries to it; this method coalesces these text nodes. The same precaution applies if you have processed a document preserving CDATA sections and these sections are adjacent to text nodes.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.4 and later.

    See Also

    – XPath

  • Returns the objects resulting from executing an XQuery query upon the receiver.

    Declaration

    Swift

    func objectsForXQuery(_ xquery: String, error error: NSErrorPointer) -> [AnyObject]?

    Objective-C

    - (NSArray *)objectsForXQuery:(NSString *)xquery error:(NSError **)error

    Parameters

    xquery

    A string that expresses an XQuery query.

    error

    If query errors occur, indirectly returns an NSError object describing the errors.

    Discussion

    The receiver acts as the context item for the query (“.”). If the receiver has been changed after parsing to have multiple adjacent text nodes, you should invoke the NSXMLElement method normalizeAdjacentTextNodesPreservingCDATA: (with an argument of NOfalse) to coalesce the text nodes before querying .This convenience method invokes objectsForXQuery:constants:error: with nil for the constants dictionary.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.4 and later.

    See Also

    – XPath

  • Returns the objects resulting from executing an XQuery query upon the receiver.

    Declaration

    Swift

    func objectsForXQuery(_ xquery: String, constants constants: [NSObject : AnyObject]!, error error: NSErrorPointer) -> [AnyObject]?

    Objective-C

    - (NSArray *)objectsForXQuery:(NSString *)xquery constants:(NSDictionary *)constants error:(NSError **)error

    Parameters

    xquery

    A string that expresses an XQuery query.

    constants

    A dictionary containing externally declared constants where the name of each constant variable is a key.

    error

    If query errors occur, indirectly returns an NSError object describing the errors.

    Discussion

    The receiver acts as the context item for the query (“.”). If the receiver has been changed after parsing to have multiple adjacent text nodes, you should invoke the NSXMLElement method normalizeAdjacentTextNodesPreservingCDATA: (with an argument of NOfalse) to coalesce the text nodes before querying.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.4 and later.

    See Also

    – XPath

  • Returns the XPath expression identifying the receiver’s location in the document tree.

    Declaration

    Swift

    var XPath: String! { get }

    Objective-C

    @property(readonly, copy) NSString *XPath

    Discussion

    For example, this method might return a string such as “foo/bar[2]/baz”. The result of this method can be used directly in the nodesForXPath:error: and objectsForXQuery:constants:error: methods.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.4 and later.

  • Returns the local name of the receiver.

    Declaration

    Swift

    var localName: String? { get }

    Objective-C

    @property(readonly, copy) NSString *localName

    Return Value

    A string containing the local name of the receiver.

    Discussion

    The local name is the part of a node name that follows a namespace-qualifying colon or the full name if there is no colon. For example, “chapter” is the local name in the qualified name “acme:chapter”.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.4 and later.

  • Returns the local name from the specified qualified name.

    Declaration

    Swift

    class func localNameForName(_ qName: String) -> String!

    Objective-C

    + (NSString *)localNameForName:(NSString *)qName

    Parameters

    qName

    A string that is a qualified name.

    Discussion

    For example, if the qualified name is “bst:title”, this method returns “title”.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.4 and later.

  • Returns the prefix of the receiver’s name.

    Declaration

    Swift

    var prefix: String? { get }

    Objective-C

    @property(readonly, copy) NSString *prefix

    Return Value

    A string containing the receiver’s prefix. This method returns an empty string if the receiver’s name is not qualified by a namespace.

    Discussion

    The prefix is the part of a namespace-qualified name that precedes the colon. For example, “acme” is the prefix in the qualified name “acme:chapter”.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.4 and later.

  • Returns the prefix from the specified qualified name.

    Declaration

    Swift

    class func prefixForName(_ qName: String) -> String?

    Objective-C

    + (NSString *)prefixForName:(NSString *)qName

    Parameters

    qName

    A string that is a qualified name.

    Discussion

    For example, if the qualified name is “bst:title”, this method returns “bst”.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.4 and later.

  • NSXMLNode declares the following constants of type NSXMLNodeKind for specifying a node’s kind in the initializer methods initWithKind: and initWithKind:options::

    Declaration

    Swift

    enum NSXMLNodeKind : UInt { case NSXMLInvalidKind case NSXMLDocumentKind case NSXMLElementKind case NSXMLAttributeKind case NSXMLNamespaceKind case NSXMLProcessingInstructionKind case NSXMLCommentKind case NSXMLTextKind case NSXMLDTDKind case NSXMLEntityDeclarationKind case NSXMLAttributeDeclarationKind case NSXMLElementDeclarationKind case NSXMLNotationDeclarationKind }

    Objective-C

    enum { NSXMLInvalidKind = 0, NSXMLDocumentKind, NSXMLElementKind, NSXMLAttributeKind, NSXMLNamespaceKind, NSXMLProcessingInstructionKind, NSXMLCommentKind, NSXMLTextKind, NSXMLDTDKind, NSXMLEntityDeclarationKind, NSXMLAttributeDeclarationKind, NSXMLElementDeclarationKind, NSXMLNotationDeclarationKind }; typedef NSUInteger NSXMLNodeKind;

    Constants

    • NSXMLInvalidKind

      NSXMLInvalidKind

      Indicates a node object created without a valid kind being specified (as returned by the kind method).

      Available in OS X v10.4 and later.

    • NSXMLDocumentKind

      NSXMLDocumentKind

      Specifies a document node.

      Available in OS X v10.4 and later.

    • NSXMLElementKind

      NSXMLElementKind

      Specifies an element node.

      Available in OS X v10.4 and later.

    • NSXMLAttributeKind

      NSXMLAttributeKind

      Specifies an attribute node

      Available in OS X v10.4 and later.

    • NSXMLNamespaceKind

      NSXMLNamespaceKind

      Specifies a namespace node.

      Available in OS X v10.4 and later.

    • NSXMLProcessingInstructionKind

      NSXMLProcessingInstructionKind

      Specifies a processing-instruction node.

      Available in OS X v10.4 and later.

    • NSXMLCommentKind

      NSXMLCommentKind

      Specifies a comment node.

      Available in OS X v10.4 and later.

    • NSXMLTextKind

      NSXMLTextKind

      Specifies a text node.

      Available in OS X v10.4 and later.

    • NSXMLDTDKind

      NSXMLDTDKind

      Specifies a document-type declaration (DTD) node.

      Available in OS X v10.4 and later.

    • NSXMLEntityDeclarationKind

      NSXMLEntityDeclarationKind

      Specifies an entity-declaration node.

      Available in OS X v10.4 and later.

    • NSXMLAttributeDeclarationKind

      NSXMLAttributeDeclarationKind

      Specifies an attribute-list declaration node.

      Available in OS X v10.4 and later.

    • NSXMLElementDeclarationKind

      NSXMLElementDeclarationKind

      Specifies an element declaration node.

      Available in OS X v10.4 and later.

    • NSXMLNotationDeclarationKind

      NSXMLNotationDeclarationKind

      Specifies a notation declaration node.

      Available in OS X v10.4 and later.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.4 and later.

  • These constants are input and output options for all NSXMLNode objects (unless otherwise indicated), including NSXMLDocument objects. You can specify these options (OR’ing multiple options) in the NSXMLNode methods initWithKind:options: and XMLStringWithOptions:.

    Declaration

    Swift

    var NSXMLNodeOptionsNone: UInt32 { get } var NSXMLNodeIsCDATA: UInt32 { get } var NSXMLNodeExpandEmptyElement: UInt32 { get } var NSXMLNodeCompactEmptyElement: UInt32 { get } var NSXMLNodeUseSingleQuotes: UInt32 { get } var NSXMLNodeUseDoubleQuotes: UInt32 { get } var NSXMLNodeLoadExternalEntitiesAlways: UInt32 { get } var NSXMLNodeLoadExternalEntitiesSameOriginOnly: UInt32 { get } var NSXMLNodeLoadExternalEntitiesNever: UInt32 { get } var NSXMLNodePrettyPrint: UInt32 { get } var NSXMLNodePreserveNamespaceOrder: UInt32 { get } var NSXMLNodePreserveAttributeOrder: UInt32 { get } var NSXMLNodePreserveEntities: UInt32 { get } var NSXMLNodePreserveCharacterReferences: UInt32 { get } var NSXMLNodePreservePrefixes: UInt32 { get } var NSXMLNodePreserveCDATA: UInt32 { get } var NSXMLNodePreserveWhitespace: UInt32 { get } var NSXMLNodePreserveEmptyElements: UInt32 { get } var NSXMLNodePreserveQuotes: UInt32 { get } var NSXMLNodePreserveDTD: UInt32 { get } var NSXMLNodePreserveAll: UInt32 { get }

    Objective-C

    enum { NSXMLNodeOptionsNone = 0, NSXMLNodeIsCDATA = 1 << 0, NSXMLNodeExpandEmptyElement = 1 << 1, // <a></a> NSXMLNodeCompactEmptyElement = 1 << 2, // <a/> NSXMLNodeUseSingleQuotes = 1 << 3, NSXMLNodeUseDoubleQuotes = 1 << 4, NSXMLDocumentTidyHTML = 1 << 9, NSXMLDocumentTidyXML = 1 << 10, NSXMLDocumentValidate = 1 << 13, NSXMLNodeLoadExternalEntitiesAlways = 1UL << 14, NSXMLNodeLoadExternalEntitiesSameOriginOnly = 1UL << 15, NSXMLNodeLoadExternalEntitiesNever = 1UL << 19, NSXMLDocumentXInclude = 1 << 16, NSXMLNodePrettyPrint = 1 << 17, NSXMLDocumentIncludeContentTypeDeclaration = 1 << 18, NSXMLNodePreserveNamespaceOrder = 1 << 20, NSXMLNodePreserveAttributeOrder = 1 << 21, NSXMLNodePreserveEntities = 1 << 22, NSXMLNodePreservePrefixes = 1 << 23, NSXMLNodePreserveCDATA = 1 << 24, NSXMLNodePreserveWhitespace = 1 << 25, NSXMLNodePreserveDTD = 1 << 26, NSXMLNodePreserveCharacterReferences = 1 << 27, NSXMLNodePreserveEmptyElements = (NSXMLNodeExpandEmptyElement | NSXMLNodeCompactEmptyElement ), NSXMLNodePreserveQuotes = (NSXMLNodeUseSingleQuotes | NSXMLNodeUseDoubleQuotes ), NSXMLNodePreserveAll = ( NSXMLNodePreserveNamespaceOrder | NSXMLNodePreserveAttributeOrder | NSXMLNodePreserveEntities | NSXMLNodePreservePrefixes | NSXMLNodePreserveCDATA | NSXMLNodePreserveEmptyElements | NSXMLNodePreserveQuotes | NSXMLNodePreserveWhitespace | NSXMLNodePreserveDTD | NSXMLNodePreserveCharacterReferences | 0xFFF00000 ) // high 12 bits };

    Constants

    • NSXMLNodeOptionsNone

      NSXMLNodeOptionsNone

      No options are requested for this input or output action.

      Available in OS X v10.4 and later.

    • NSXMLNodeIsCDATA

      NSXMLNodeIsCDATA

      Specifies that a text node contains and is written out as a CDATA section.

      Available in OS X v10.4 and later.

    • NSXMLNodeExpandEmptyElement

      NSXMLNodeExpandEmptyElement

      Requests that an element should be expanded when empty; for example, <flag></flag>. This is the default.

      Available in OS X v10.4 and later.

    • NSXMLNodeCompactEmptyElement

      NSXMLNodeCompactEmptyElement

      Requests that an element should be contracted when empty; for example, <flag/>.

      Available in OS X v10.4 and later.

    • NSXMLNodeUseSingleQuotes

      NSXMLNodeUseSingleQuotes

      Requests that NSXML use single quotes for the value of an attribute or namespace node.

      Available in OS X v10.4 and later.

    • NSXMLNodeUseDoubleQuotes

      NSXMLNodeUseDoubleQuotes

      Requests that NSXML use double quotes for the value of an attribute or namespace node. This is the default.

      Available in OS X v10.4 and later.

    • NSXMLNodeLoadExternalEntitiesAlways

      NSXMLNodeLoadExternalEntitiesAlways

      Requests that external entities are always loaded.

      Requests that external entities are always loaded. You may choose only one of NSXMLNodeLoadExternalEntitiesAlways, NSXMLNodeLoadExternalEntitiesSameOriginOnly, or NSXMLNodeLoadExternalEntitiesNever or none.

      Choosing none results in the system-default behavior. For applications linked on OS X v10.6 and earlier, this is NSXMLNodeLoadExternalEntitiesAlways. For applications linked on OS X v10.7 or later, all entities that don't require network access are loaded.

      If an external entity fails to load, the document is invalid and the parse is aborted with an error.

      Available in OS X v10.7 and later.

    • NSXMLNodeLoadExternalEntitiesSameOriginOnly

      NSXMLNodeLoadExternalEntitiesSameOriginOnly

      Requests that external entities are always loaded and only applies when a URL has been provided.

      It loads entities with target URLs that match the host, scheme, and port of the document URL.You may choose only one of NSXMLNodeLoadExternalEntitiesAlways, NSXMLNodeLoadExternalEntitiesSameOriginOnly, or NSXMLNodeLoadExternalEntitiesNever or none.

      Choosing none results in the system-default behavior. For applications linked on OS X v10.6 and earlier, this is NSXMLNodeLoadExternalEntitiesAlways. For applications linked on OS X v10.7 or later, all entities that don't require network access are loaded.

      If an external entity fails to load, the document is invalid and the parse is aborted with an error.

      Available in OS X v10.7 and later.

    • NSXMLNodeLoadExternalEntitiesNever

      NSXMLNodeLoadExternalEntitiesNever

      Requests that external entities are never loaded.

      You may choose only one of NSXMLNodeLoadExternalEntitiesAlways, NSXMLNodeLoadExternalEntitiesSameOriginOnly, or NSXMLNodeLoadExternalEntitiesNever or none.

      Requests that external entities are never loaded. You may choose only one of NSXMLNodeLoadExternalEntitiesAlways, NSXMLNodeLoadExternalEntitiesSameOriginOnly, or NSXMLNodeLoadExternalEntitiesNever or none.

      Choosing none results in the system-default behavior. For applications linked on OS X v10.6 and earlier, this is NSXMLNodeLoadExternalEntitiesAlways. For applications linked on OS X v10.7 or later, all entities that don't require network access are loaded.

      Available in OS X v10.7 and later.

    • NSXMLNodePrettyPrint

      NSXMLNodePrettyPrint

      Print this node with extra space for readability. (Output)

      Available in OS X v10.4 and later.

    • NSXMLNodePreserveNamespaceOrder

      NSXMLNodePreserveNamespaceOrder

      Requests NSXML to preserve the order of namespace URI definitions as in the source XML.

      Available in OS X v10.4 and later.

    • NSXMLNodePreserveAttributeOrder

      NSXMLNodePreserveAttributeOrder

      Requests that NSXMLNode preserve the order of attributes as in the source XML.

      Available in OS X v10.4 and later.

    • NSXMLNodePreserveEntities

      NSXMLNodePreserveEntities

      Specifies that entities (&xyz;) should not be resolved for XML output of this node.

      Available in OS X v10.4 and later.

    • NSXMLNodePreserveCharacterReferences

      NSXMLNodePreserveCharacterReferences

      Specifies that character references (&#nnn;) should not be resolved for XML output of this node.

      Available in OS X v10.4 and later.

    • NSXMLNodePreservePrefixes

      NSXMLNodePreservePrefixes

      Requests NSXMLNode not to choose prefixes based on the closest namespace URI definition.

      Available in OS X v10.4 and later.

    • NSXMLNodePreserveCDATA

      NSXMLNodePreserveCDATA

      Requests that NSXMLNode preserve CDATA blocks where defined in the input XML.

      Available in OS X v10.4 and later.

    • NSXMLNodePreserveWhitespace

      NSXMLNodePreserveWhitespace

      Requests NSXMLNode to preserve whitespace characters (such as tabs and carriage returns) in the XML source that are not part of node content.

      Available in OS X v10.4 and later.

    • NSXMLNodePreserveEmptyElements

      NSXMLNodePreserveEmptyElements

      Specifies that empty elements in the input XML be preserved in their contracted or expanded form.

      Available in OS X v10.4 and later.

    • NSXMLNodePreserveQuotes

      NSXMLNodePreserveQuotes

      Specifies that the quoting style used in the input XML (single or double quotes) be preserved.

      Available in OS X v10.4 and later.

    • NSXMLNodePreserveDTD

      NSXMLNodePreserveDTD

      Specifies that declarations in a DTD should be preserved until it the DTD is modified. For example, parameter entities are by default expanded; with this option, they are written out as they originally occur in the DTD.

      Available in OS X v10.4 and later.

    • NSXMLNodePreserveAll

      NSXMLNodePreserveAll

      Turns on all preservation options: attribute and namespace order, entities, prefixes, CDATA, whitespace, quotes, and empty elements. You should try to turn on preservation options selectively because turning on all preservation options significantly affects performance.

      Available in OS X v10.4 and later.

    Discussion

    The options with “Preserve” in their names are applicable only when external sources of XML are parsed; they have no effect on node objects that are programmatically created. Other options are used in initialization and output methods of NSXMLDocument; see the NSXMLDocument reference documentation for details.