🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.lang.ruby
Article #27

Re: Ruby i XML

#27
From: Jaroslaw Zabiello
Date: Mon, 10 Jul 2006 08:43
24 lines
1468 bytes
On Mon, 10 Jul 2006 10:33:24 +0200, Marcin Mielżyński wrote:

>> Czego najlepiej używać aby w Ruby wyciagnąc dane z paru pól w XML?
>> Najlepiej aby to było tak *proste* jak simplexml w PHP5. 
> 
> jeśli proste i xml jest mały to najlepiej rexml

Używam REXML ale nie podoba mi się sposób w jaki wyłuskuje się elementy.
Rozumiem, że XPATH to dobra rzecz ale ja chcę jeszcze prościej. Zamiast 

doc = REXML::Document.new(xml)
doc.elements.each('/A/B/C') do |element|
  c = element.text
end

chciałbym coś w stylu:

c = doc.A.B.C

Da się? W dokumentacji nic nie ma (w ogóle jest bardzo słaba). 

-- 
Jarosław Zabiełło
http://blog.zabiello.com
Technical Details
Message-ID: <ve51y13h3c9d.16otfd82xca12$.dlg@40tude.net>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!not-for-mail
References: <1imfcmkz5g9om.4n9wovvixr47.dlg@40tude.net> <e8t3c9$bjl$1@news.onet.pl>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!not-for-mail
From: Jaroslaw Zabiello <hipertracker@gmail.com>
Newsgroups: pl.comp.lang.ruby
Subject: Re: Ruby i XML
Date: Mon, 10 Jul 2006 09:43:33 +0100
Organization: "Portal Gazeta.pl -> http://www.gazeta.pl"
Lines: 24
Message-ID: <ve51y13h3c9d.16otfd82xca12$.dlg@40tude.net>
References: <1imfcmkz5g9om.4n9wovvixr47.dlg@40tude.net> <e8t3c9$bjl$1@news.onet.pl>
NNTP-Posting-Host: 213.190.141.10
Mime-Version: 1.0
X-Trace: inews.gazeta.pl 1152521014 19889 213.190.141.10 (10 Jul 2006 08:43:34 GMT)
X-Complaints-To: usenet@agora.pl
NNTP-Posting-Date: Mon, 10 Jul 2006 08:43:34 +0000 (UTC)
X-User: newsgate2
User-Agent: 40tude_Dialog/2.0.15.1
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit