Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Ruby
Using XPath to retrieve an XML element which contains a given text
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="anne001, post: 4615107"] 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 = <<EOF <dataformats> <dataformat> <fileidentifiers> <fileidentifier>CFMT</fileidentifier> </fileidentifiers> </dataformat> <dataformat> <fileidentifiers> <fileidentifier>SPPT</fileidentifier> </fileidentifiers> </dataformat> </dataformats> EOF doc = Document.new string xpathquery="//dataformat[contains(fileidentifier, SPPT)]" p XPath.first(doc,xpathquery).to_s [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Ruby
Using XPath to retrieve an XML element which contains a given text
Top