Skip to content

Comments

docs: add comprehensive XPATH function examples#832

Open
jonathan-fulton wants to merge 1 commit intoMontFerret:masterfrom
jonathan-fulton:docs/add-xpath-examples
Open

docs: add comprehensive XPATH function examples#832
jonathan-fulton wants to merge 1 commit intoMontFerret:masterfrom
jonathan-fulton:docs/add-xpath-examples

Conversation

@jonathan-fulton
Copy link
Contributor

Summary

Expand the xpath.fql example file with comprehensive examples of XPATH queries.

Context

As requested in #606, the documentation lacked practical examples showing how to use the XPATH function for common web scraping tasks. Users were unclear on how to query various types of metadata from HTML documents.

Changes

Enhanced examples/xpath.fql with examples demonstrating:

  • Basic queries: Extracting charset, page title, and link hrefs
  • Meta tag extraction: Getting description and other meta content by name
  • Open Graph metadata: Extracting og:url, og:title, og:image (commonly needed for social sharing info)
  • Twitter Card metadata: Extracting Twitter-specific meta tags
  • Class-based selection: Using contains() for matching CSS classes (XPath 1.0 pattern)
  • Position predicates: Selecting specific matches from result sets
  • ID-based selection: Targeting elements by ID attribute
  • Combined conditions: Using and operator in predicates

Example Output

// Get Open Graph metadata
LET ogUrl = XPATH(doc, "//meta[@property='og:url']/@content")
LET ogTitle = XPATH(doc, "//meta[@property='og:title']/@content")

Fixes #606

Expand the xpath.fql example file with more comprehensive examples of
XPATH queries including:

- Basic attribute and text content queries
- Meta tag queries (description, charset)
- Open Graph metadata extraction (og:url, og:title, og:image)
- Twitter Card metadata extraction
- Class-based element selection using contains()
- Position predicates for selecting specific matches
- ID-based selection
- Combining conditions with 'and'

These examples address common use cases for web scraping and help users
understand how to extract various types of metadata from web pages.

Fixes MontFerret#606
@ziflex
Copy link
Member

ziflex commented Feb 4, 2026

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Documentation: add examples of queries made using XPATH

2 participants