require 'rexml/document'
doc = REXML::Document.new(File.open("test.xml"))
root = doc.root
rtnValue = root.get_elements("COM1")
#rtnValue = root.elements["COM1"].text
rtnValue.each{|re|
puts re.text
}
#puts rtnValue
XML文件:
<?xml version="1.0" encoding="UTF-8"?>
<Root>
<COM1>AAAAAAAAAAA</COM1>
<COM1>AAAAAAAAbbb</COM1>
<COM2>BBBBBBBBBBB</COM2>
<COM3>CCCCCCCCCCC</COM3>
...
...
</Root>