class LibXML::XML::XPath::Expression

The XML::XPath::Expression class is used to compile XPath expressions so they can be parsed only once but reused multiple times.

doc = XML::Document.string(IO.read('some xml file'))
expr = XPath::Expression.new('//first')
doc.root.each do |node|
 result = node.find(expr) # many, many, many times
 # ...
end