Forum: Ruby rexml/document problem

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
645cd831f3b2eee7ba15fd8256796c57?d=identicon&s=25 Cool Wong (coolwong)
on 2007-07-20 02:41
[code]

<?xml version="1.0"?>
<a>

  <b prefix="A" num="1" />
  <b perfix="B" num="2" />
  <b prefix="C" num="3" />
  <b prefix="D" num="4" />
  <b prefix="F" num="5" />
</a>
[/code]

This is my xml file data. There include several <b> in the xml file. i
can read the 1st data:

puts root.elements["b"].attributes["prefix"]

Now i cannot read the <b> 1 by 1. How can i read the <b> and write the
output is:

"A"
"B"
"C"
"D"
"E"
1040215636f35f752ce36af2cdd61458?d=identicon&s=25 Phlip (Guest)
on 2007-07-20 04:11
(Received via mailing list)
Cool Wong wrote:

>
> "C"
> "D"
> "E"

REXML::XPath.each(root, '//b') do |node|
    p node.text
end
645cd831f3b2eee7ba15fd8256796c57?d=identicon&s=25 Cool Wong (coolwong)
on 2007-07-20 05:53
Phlip wrote:
> Cool Wong wrote:
>
>>
>> "C"
>> "D"
>> "E"
>
> REXML::XPath.each(root, '//b') do |node|
>     p node.text
> end



if i want to update or edit the content in the xml file, how can i
update it??
This topic is locked and can not be replied to.