|
Problem with REXML: msg#01136lang.ruby.general
Hi! I think I have an problem understanding REXML. let's say I have this XML file: <?xml version="1.0" ?> <INVENTORY> <BOOK> <TITLE>lala</TITLE> <AUTHOR>hans</AUTHOR> </BOOK> <BOOK> <TITLE>lele</TITLE> <AUTHOR>hens</AUTHOR> </BOOK> </INVENTORY> Now I want my application to get the author of the book called "lala". In my perfect world something like that would work: doc.each_element("BOOK") {|book| puts book.element("AUTHOR") if "lala" == book.element("TITLE")} or, even better: @element = Element.new() doc.each_element("BOOK") {|book| @element = book if "lala" == book.element("TITLE")} working with the documentation of REXML, it seems, that the usual way to access a certein element is over its attributes, which is pretty useless in my example. And it seems impossible to get the parent of an element. have I missed something? regards, Andreas.
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Unicode in Ruby now?, Dave Thomas |
|---|---|
| Next by Date: | FXRuby usage: Capturing results from an FXDialogBox, Stephan Kämper |
| Previous by Thread: | ruby-dev summary 17875-17964, TAKAHASHI Masayoshi |
| Next by Thread: | Re: Problem with REXML, Tobias Reif |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |