Tutorial

This document describes how to use LuaCS step by step. If you don't install LuaCS yet, install LuaCS before you read this document.

Parse CSS Selectors

TODO

Convert to XPath

You can convert CSS Selectors to XPath.

Example:

local luacs = require("luacs")

-- Convert CSS Selectors to XPaths
local xpaths = luacs.to_xpaths("ul li, a.external")

for _, xpath in ipairs(xpaths) do
  print(xpath)
  -- /descendant::*[local-name()='ul']/descendant::*[local-name()='li']
  -- /descendant::*[local-name()='a'][@class][contains(concat(' ', normalize-space(@class), ' '), ' external ')]
end

You can use xmlua.Searchable.css_select to search nodes from DOM by CSS Selectors.

Next step

Now, you knew all major LuaCS features! If you want to understand each feature, see reference manual for each feature.