Edit AllPages

General/XPath is a sort of query language for XML. You can access any node within a document with a simple expression. The shorthand form looks much like a UNIX file path.

Consider this simple XML-document

Theo Hultberg

/persons/person[1] retrieves the first person-element that is a child of the root node (“/” is the root node).

/persons/person[@id="811201"] retrieves all person-elements that are children of the root element and has an attribute (“@") with the name "id" that has the value "811201".

//name retrieves all name-elements in the document

//person/@id retrieves all id attributes of person-elements in the document.

/persons//name retrieves all name-elements in the document that are descendants of person-elements (that are children of the root node)

Double-quotes and single-quotes are equivalent.

See for more info.

– General/TheoHultberg/Iconara

General/IconaraDOM has basic General/XPath-support for working with XML-documents in Cocoa. General/XMLTree has some General/XPath-support, too.

Tiger introduces the General/NSXml classes, which include General/XPath support.