From: anne001 Date: 2008-08-11T04:39:01+09:00 Subject: Using XPath to retrieve an XML element which contains a given text This code returns the first dataformat element. And yet the second dataformat is the one containing SPPT. What am I doing wrong? require "rexml/document" include REXML string = < CFMT SPPT EOF doc = Document.new string xpathquery="//dataformat[contains(fileidentifier, SPPT)]" p XPath.first(doc,xpathquery).to_s