ruby yaml ypath like xpath ?
Posted
by gurpal2000
on Stack Overflow
See other posts from Stack Overflow
or by gurpal2000
Published on 2010-03-20T16:46:02Z
Indexed on
2010/03/20
16:51 UTC
Read the original article
Hit count: 181
Hi i have a yaml file like so
---
data:
- date: "2004-06-11"
description: First description
- date: "2008-01-12"
description: Another descripion
How can i do a "ypath" query similar to xpath for xml ? Something like "get the description where the date is 2004-06-11"
YAML.parse_file('myfile.yml').select('/data/*/date == 2004-06-11')
How do you do it, and if that's possible how can i similarly edit the description by 'ypath' ?
Thanks
© Stack Overflow or respective owner