xidel icon indicating copy to clipboard operation
xidel copied to clipboard

Add examples/ directory

Open ctrlcctrlv opened this issue 2 years ago • 1 comments

Promised in main README. Hopefully the beginning of many examples that don't require network connectivity.

ctrlcctrlv avatar Jan 28 '23 13:01 ctrlcctrlv

xquery version "3.1"; [...] parse-xml('<html>...</html>')

xquery version "3.1-xidel"; [...] parse-html('<html>...</html>') (parse-html())

xidel --html --xquery3="$(cat examples/1.xq)"

There's --extract-file or -e @ for that, and --output-node-indent for some prettification:

xidel -s --extract-file="examples/1.xq" --output-format=html --output-node-indent
xidel -s -e @"examples/1.xq" --output-format=html --output-node-indent
<!DOCTYPE html>
<table>
  <tbody>
    <tr class="C_123 hascol1" id="123">
      <td>123</td>
      <!--  -->
    </tr>
    <tr class="C_456 C_other hascol1 hascomment" id="456">
      <td>456</td>
      <!-- other -->
    </tr>
    <tr class="C_foo C_columns hascol1 hascomment" id="foo">
      <td>foo</td>
      <!-- columns -->
    </tr>
    <tr class="C_bar C_are hascol1 hascomment" id="bar">
      <td>bar</td>
      <!-- are -->
    </tr>
    <tr class="C_xyz C_ignored C_zomg hascol1 hascomment zomg" id="xyz">
      <td name="zomg">xyz</td>
      <!-- ignored -->
    </tr>
  </tbody>
</table>

However, I think the wiki is a much better place for examples. It's still on my long to-do-list. And let's then start off with some easy examples first, because let's face it, this particular example is really for the advanced Xidel-user.

Reino17 avatar Jan 28 '23 22:01 Reino17