Building Complex Structures
Atomic values are not enough.
The fork operator “#” permits to follow a path along various subpaths. Results are put together into a list.
Following the previous example, we can extract the entire stock information and put it in one structure.
html.body.center.table[i:*]
( .tr[0].td[0].b[0].txt // name
# .tr[0].td[0].b[0]->pcdata[1].txt, match /[(](.*?):/ // trading place
# .tr[0].td[0].b[0]->pcdata[1].txt, match /:(.*?)[)]/ // ticker
# .tr[1].td[0].b[0].txt // last trade
# .tr[1].td[3].pcdata[1].txt // volume
# .tr[1].td[1].txt, match /[(](.*?)[)]/ // change %
# .tr[2].td[0].txt, match /Range(.*)/, split /-/ // Day range
# .tr[3].td[0].txt, match /Range(.*)/, split /-/ // Year range
where html.body.center.table[i].tr[0].td[0].getAttr(colspan) = "7";