DOMXPath Class Reference

List of all members.

Detailed Description

Creates XPath expression objects.


Static Public Member Functions

(DOMXPathExpression *)  expressionWithString:

Member Function Documentation

+ (DOMXPathExpression *) expressionWithString: (NSString *)  expr  
 

Creates a compiled representation of a XPath expression from a string.

Expression objects are compiled, so if you are using the same expression more than once, you should try to reuse the expression object.

Attention:
  • It should be noted that the XPath compiler is not complete. It recognizes only trivial predicates, and the evaluation engine does not recognize namespaces. Moreover, for some unsupported expressions the compiler may not raise an exception. THE COMPILER SHOULD NOT BE USED AS A REFERENCE AS TO WHAT IS A VALID EXPRESSION. Test your expressions thouroughly. The compiler and evaluation engine will recognize more advanced expressions in later versions of the framework.
  • There is no guarantee that complicated expressions will be evaluated correctly, especially when it comes to predicates. Please report any bugs you encounter, and later versions might work better.

  • The XPath specification allows for liberal use of whitespace in expressions, this implementation tries to adhere to that, but may not always. If you have problems, try to remove whitespace and try again. The best is probably to avoid whitespace altogether.

  • Namespaces are not supported. Elements are compared with DOMElement::nodeName (which is equivalent to DOMElement::name), so if the element name has a prefix, it must be included in the expression. Future implementations will support namespaces in a proper way.

Exceptions:
DOMMalformedXPathExpressionException Raised if the compiler detects a syntax error in the expression string. The reason of the exception should state what the error was.