# Rexml/document problem

**URL:** <https://www.ruby-forum.com/t/rexml-document-problem/109907>\
**Category:** Ruby\
**Created:** [July 20, 2007, 2:41am UTC](https://www.ruby-forum.com/t/rexml-document-problem/109907 "2007-07-20T02:41:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![coolwong](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/d9b06d/32.png) [@coolwong](https://www.ruby-forum.com/u/coolwong)\
**Post date:** [July 20, 2007, 2:41am UTC](https://www.ruby-forum.com/t/rexml-document-problem/109907/1 "2007-07-20T02:41:22Z")

</div>

```auto

<?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>
```

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

puts root.elements[“b”].attributes[“prefix”]

Now i cannot read the **1 by 1. How can i read the and write the  
output is:**

“A”  
“B”  
“C”  
“D”  
“E”

---

<div class="post-metadata">

**Author:** ![coolwong](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/d9b06d/32.png) [@coolwong](https://www.ruby-forum.com/u/coolwong)\
**Post date:** [July 20, 2007, 4:11am UTC](https://www.ruby-forum.com/t/rexml-document-problem/109907/2 "2007-07-20T04:11:31Z")

</div>

Cool W. wrote:

> “C”  
> “D”  
> “E”

REXML::XPath.each(root, ‘//b’) do |node|  
p node.text  
end

---

<div class="post-metadata">

**Author:** ![coolwong](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/d9b06d/32.png) [@coolwong](https://www.ruby-forum.com/u/coolwong)\
**Post date:** [July 20, 2007, 5:53am UTC](https://www.ruby-forum.com/t/rexml-document-problem/109907/3 "2007-07-20T05:53:51Z")

</div>

Phlip wrote:

> Cool W. 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??
