Re: YPath into nested omaps

Phlip <[email protected]>
Newsgroups gmane.text.yaml.general
Message-ID <[email protected]>
> >      sauce = "--- !map
> >  - a:
> >    - !omap
> >      - sku         : BL394D
> >      - quantity    : 4
> >      - description : Basketball
> >  - b: two"
> >      o = YAML::parse(sauce)
> >      p o.emit

> How close is YPath to working there? '/a/sku' should work, right?

I got this to work:

    assert_equal 'BL394D', o.select('/0/a/0/0/sku')[0].value

The technical problem is I can't tell if it follows the chain of Seq
and Map objects that represent the OMap, or if there are too many
redundant /0 segments.

The esthetic problem is I'm trying to write a paper, and I need to
show low-level elegance here.

Curiously, '//a//sku' works correctly! I will proceed with that tweak...

-- 
  Phlip
  http://c2.com/cgi/wiki?ZeekLand  <-- NOT a blog!!

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.