logo       

Re: Problem with REXML: msg#01174

lang.ruby.general

Subject: Re: Problem with REXML

Hi,

From: Andreas Pinkert <the_supernova@xxxxxxx>
Subject: Problem with REXML
Date: Tue, 13 Aug 2002 05:48:42 +0900
Message-ID: <aj967j$4br$1@xxxxxxxxxxxxxxxxxxxxxx>

> doc.each_element("BOOK") {|book| puts book.element("AUTHOR") if
> "lala" == book.element("TITLE")}

What about this?

REXML::XPath.each(doc,"//AUTHOR[../TITLE/text()='lala']") do |author|
puts author # This is "puts autor.text" if you want to get "hans".
end

> or, even better:
>
> @element = Element.new()
> doc.each_element("BOOK") {|book| @element = book if
> "lala" == book.element("TITLE")}

And

REXML::XPath.each(doc,"//BOOK[TITLE/text()='lala']") do |book|
@element = book
end

yours,

======================
SUTOU Kouhei
kou@xxxxxxxxx



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise