# REXML translate (XPath?)

**URL:** <https://www.ruby-forum.com/t/rexml-translate-xpath/183339>\
**Category:** Ruby\
**Created:** [February 12, 2010, 1:49am UTC](https://www.ruby-forum.com/t/rexml-translate-xpath/183339 "2010-02-12T01:49:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aginghipster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e9c0ed/32.png) [@aginghipster](https://www.ruby-forum.com/u/aginghipster)\
**Post date:** [February 12, 2010, 1:49am UTC](https://www.ruby-forum.com/t/rexml-translate-xpath/183339/1 "2010-02-12T01:49:37Z")

</div>

Can somebody explain or put me to an explanation of how to use  
REXML::Functions::translate ?

I’d like to turn this: group\_list.elements[“entry[title=’#{name}’]”]

. . . into a case insensitive lookup. Do I put the translation into  
the XPath in that line? Do I need a separate translation line?

Thanks,  
Andrew

---

<div class="post-metadata">

**Author:** ![aginghipster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e9c0ed/32.png) [@aginghipster](https://www.ruby-forum.com/u/aginghipster)\
**Post date:** [February 12, 2010, 9:15pm UTC](https://www.ruby-forum.com/t/rexml-translate-xpath/183339/2 "2010-02-12T21:15:49Z")

</div>

On Feb 11, 7:42 pm, “Andrew C.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Can somebody explain or put me to an explanation of how to use  
> REXML::Functions::translate ?
> 
> I’d like to turn this: group\_list.elements[“entry[title=‘#{name}’]”]
> 
> . . . into a case insensitive lookup. Do I put the translation into  
> the XPath in that line? Do I need a separate translation line?
> 
> Thanks,  
> Andrew

This would be the correct XPath:

group\_list.elements[“entry[translate(title,  
‘ABCDEFGHIJKLMNOPQRSTUVWXYZ’,  
‘abcdefghijklmnopqrstuvwxyz’)=‘#{name.downcase}’]”]

but I don’t know if REXML can handle it, because it’s not fully XPath  
compliant. I’d use an XPath-compliant parser like Nokogiri if this is  
an issue.

– Mark.

---

<div class="post-metadata">

**Author:** ![aginghipster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e9c0ed/32.png) [@aginghipster](https://www.ruby-forum.com/u/aginghipster)\
**Post date:** [February 12, 2010, 10:15pm UTC](https://www.ruby-forum.com/t/rexml-translate-xpath/183339/3 "2010-02-12T22:15:31Z")

</div>

That appears to work for REXML. Thanks Mark.
