Hi Peter,
What you want is to get the array of specific nodes, isn't it??
If it's true, see code below:
xmltest.rb :
require 'rexml/document'
xmlin = <<EOD
<a>
<b>one</b>
<c>two</c>
<d>
<e>three</e>
<f>four</f>
</d>
</a>
EOD
xml = REXML::Document.new(xmlin)
puts xml.elements.to_a('/a/d')
--
then, you can iterate with the nodes of 'd', including knowing
the number of 'd' nodes with '.size' method, right??
Regards,
umitanuki
Peter Fitzgibbons wrote:
> HI Jeff,
>
> xmltest.rb :
> require 'rexml/document'
>
> xmlin = <<EOD
> <a>
> <b>one</b>
> <c>two</c>
> <d>
> <e>three</e>
> <f>four</f>
> </d>
> </a>
> EOD
>
> xml = REXML::Document.new(xmlin)
> puts xml.elements['/a/d'].size
> puts xml.elements['/a/d']
>
>
> output :
> 5
> <d>
> <e>three</e>
> <f>four</f>
> </d>
>
> xml.elements['/a/d'] returns the entire xml tree under/including /a/d
>
> I want this to return 1 (the number of "d" elements in the list)
>
>
>