Contents

nodes(forXPath:)

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

Declaration

func nodes(forXPath xpath: String) throws -> [XMLNode]

Parameters

  • xpath:

    A string that expresses an XPath query.

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 false) 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.

See Also

Executing Queries