From: Mark Volkmann Date: 2007-09-25T04:41:38+09:00 Subject: Re: getting XPath in REXML to dive deeper --Apple-Mail-228--245183161 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed On Sep 24, 2007, at 2:34 PM, Gavin Kistner wrote: > Peter Bailey wrote: >> I'm finally using REXML instead of plain vanilla Ruby to convert XML >> data. I've learned a bit about XPath and how REXML can use it. >> I've got >> a sample XML file whose root element is . Underneath >> that >> element are a bunch of children elements. So, when I do the >> instruction >> listed below, I get all of them. But, I don't get the last two >> elements >> that, to me anyway, are children, too. The only thing different about >> them is that they have children, too. Does anyone know the >> nomenclature >> for getting ALL of the children of an element, not just those that >> are >> immediate children. I guess I want grandkids, too! >> >> XPath.each(doc, "//registration/*") { |element| puts element.text } > > The term you are looking for is 'descendants'. In XPath, '/' is > shorthand for the 'child' axis. You want the 'descendant' axis, which > has the shorthand (that you already used) of '//'. > > So "//registration//*" is "At any level, find an element named > 'registration', and then find every element below any of them." > > You possible want "registration//*" which is "every element in the > entire XML file at every level except for the root node", Doesn't he want "/registration//*" ? Note the slash at the beginning. --- Mark Volkmann --Apple-Mail-228--245183161--