cpp-ElementTree
Python ElementTree-alike XML API for C++
Public Member Functions | List of all members
etree::XPath Class Reference

Manages a compiled XPath expression. More...

#include <element.hpp>

Public Member Functions

 XPath (const char *s)
 Compile an expression from a character array. More...
 
 XPath (const string &s)
 Compile an expression from a STL string. More...
 
 XPath (const string &s, const XPathContext &context)
 Compile an expression from a STL string. More...
 
 XPath (const XPath &other)
 Copy an expression. More...
 
 ~XPath ()
 Destroy the compiled expression.
 
const string & expr () const
 Return a string representation of the compiled expression.
 
Nullable< Elementfind (const Element &e) const
 Return the first matching Element, if any, matching the expression. More...
 
vector< Elementfindall (const Element &e) const
 Return all Elements matching the expression. More...
 
string findtext (const Element &e, const string &default_="") const
 Return the text part of the first matching element. More...
 
XPathoperator= (const XPath &other)
 Replace this expression with another. More...
 
vector< Elementremoveall (Element &expr) const
 Like XPath::findall, except remove each discovered element before returning it.
 

Detailed Description

Manages a compiled XPath expression.

Constructor & Destructor Documentation

etree::XPath::XPath ( const char *  s)

Compile an expression from a character array.

Parameters
sXPath expression.
etree::XPath::XPath ( const string &  s)

Compile an expression from a STL string.

Parameters
sXPath expression.
etree::XPath::XPath ( const string &  s,
const XPathContext context 
)

Compile an expression from a STL string.

Parameters
sXPath expression.
contextXPathContext object.
etree::XPath::XPath ( const XPath other)

Copy an expression.

Parameters
otherXPath expression to copy.

Member Function Documentation

Nullable< Element > etree::XPath::find ( const Element e) const

Return the first matching Element, if any, matching the expression.

Parameters
eRoot element to search from.
Returns
Matching Element, if any.
std::vector< Element > etree::XPath::findall ( const Element e) const

Return all Elements matching the expression.

Parameters
eRoot element to search from.
Returns
Matching Elements.
std::string etree::XPath::findtext ( const Element e,
const string &  default_ = "" 
) const

Return the text part of the first matching element.

Parameters
eRoot element to search from.
default_String to return if text is not found.
Returns
Text part of the first matching element, or the empty string.
XPath & etree::XPath::operator= ( const XPath other)

Replace this expression with another.

Parameters
otherXPath expression to assign.

The documentation for this class was generated from the following files: