Skip to content
iterationlabs edited this page Sep 13, 2010 · 2 revisions

A simple script, or “dex”, looks like this:

{
  "title": "h1",
  "links(a)": [
    {
      "text": ".",
      "href": "@href"
    }
  ]
}

This returns JSON or XML output with the same structure. Applying this dex to http://www.yelp.com/biz/amnesia-san-francisco yields either:

{
  "title": "Amnesia",
  "links": [
    {
      "href": "\/",
      "text": "Yelp"
    },
    {
      "href": "\/",
      "text": "Welcome"
    },
    {
      "href": "\/signup?return_url=%2Fuser_details",
      "text": " About Me"
    },
    .....
  ]
}

or equivalently:

<dexter:root>
  <title>Amnesia</title>
  <links>
    <dexter:group>
      <href>/</href>
      <text>Yelp</text>
    </dexter:group>
    <dexter:group>
      <href>/</href>
      <text>Welcome</text>
    </dexter:group>
    <dexter:group>
      <href>/signup?return_url=%2Fuser_details</href>
      <text> About Me</text>
    </dexter:group>
    .....
  </links>
</dexter:root>

This dex could also have been expressed as:

{
  "title": "h1",
  "links(a)": [
    {
      "text": ".",
      "href": "@href"
    }
  ]
}

The “a” in links(a) is a “key selector” – an explicit grouping (with scope) for the array. You can use any XPath 1.0 or CSS3 expression as a value or a key selector. Dexter will try to be smart, and figure out which you are using. You can use CSS selectors inside XPath functions – substring-after(h1>a, ':') is a valid expression.

Clone this wiki locally