Releases: reclaimprotocol/xpath-go
v1.4.0: Unified Evaluator & 100% Test Compatibility
Refactor: Modularize evaluator, unified parser, and 100% test compatibility
- Split function_parser.go into expressions.go, function_eval.go, and function_parser.go
- Implement unified ExpressionEvaluator for all predicate types
- Add Debug flag to Options for detailed execution tracing
- Fix NodeSet truthiness and text node dot predicate parsing
- Fix nested predicate parsing bug in FunctionParser
- Achieve 100% pass rate on comprehensive test suite
v1.3.0
XPath Go v1.3.0
π― High-Compatibility XPath Library for Go
This release brings comprehensive XPath functionality with strong compatibility and precise node location tracking.
β¨ Highlights
- High Compatibility: Strives for close compatibility with web standards and jsdom
- Location Tracking: Precise character positioning in source HTML/XML
- Production Ready: Comprehensive error handling and performance optimization
What's Changed
Changelog
Other Changes
- e9e9bc2: π Bump version to v1.3.0 (@AbdulRashidReshamwala)
- 05725f8: π§ Fix ContentsOnly position tracking for raw text elements (@AbdulRashidReshamwala)
Full Changelog: v1.2.0...v1.3.0
v1.2.0
π New Features
- β¨ ContentsOnly Extraction Mode: Added new option for XPath queries that allows extracting either:
- Full elements (including tags):
<div>content</div> - Content only (inner content):
content
- Full elements (including tags):
- π CLI Support: New
--contents-onlyflag for command-line usage - π― 100% Compatibility: Maintained full test compatibility across 132+ test cases
π Documentation
- Added comprehensive XPath 2.0 compatibility analysis document
- Complete API documentation for contentsOnly functionality
- Usage examples and implementation notes
π§ Technical Improvements
- Enhanced HTML parser with precise content boundary tracking
- Added
ContentStart/ContentEndfields to Result struct - Integrated contentsOnly tests into main comprehensive test suite
- Support for dual-mode extraction across all XPath expressions
π API Changes
New Options
type Options struct {
IncludeLocation bool
OutputFormat string
ContentsOnly bool // New: Extract only inner content between tags
}New Result Fields
type Result struct {
// ... existing fields
ContentStart int // New: Start of inner content (after opening tag)
ContentEnd int // New: End of inner content (before closing tag)
}Usage Example
// Extract full elements (default)
results, _ := xpath.QueryWithOptions("//div", html, xpath.Options{
ContentsOnly: false,
})
// Extract only inner content
results, _ := xpath.QueryWithOptions("//div", html, xpath.Options{
ContentsOnly: true,
})Perfect for use cases where you need to extract text content without HTML tags while maintaining precise position tracking for all extraction modes.
v1.1.0
XPath Go v1.1.0
π― High-Compatibility XPath Library for Go
This release brings comprehensive XPath functionality with strong compatibility and precise node location tracking.
β¨ Highlights
- High Compatibility: Strives for close compatibility with web standards and jsdom
- Location Tracking: Precise character positioning in source HTML/XML
- Production Ready: Comprehensive error handling and performance optimization
What's Changed
Changelog
Other Changes
- f15412b: π― Achieve 100% XPath compatibility - Fix remaining issues (@AbdulRashidReshamwala)
- 6a724e2: π― Achieve 95.7% XPath compatibility with major improvements (@AbdulRashidReshamwala)
- 538357c: π Update documentation and prepare v1.1.0 release (@AbdulRashidReshamwala)
- 50165d2: π§ Fix HTML5 raw text element parsing for script, style, textarea tags (@AbdulRashidReshamwala)
- 5be2c12: π§ Fix complex boolean AND conditions in predicates (@AbdulRashidReshamwala)
- 11b190a: π§ Major compatibility improvements and documentation (@AbdulRashidReshamwala)
- 418c4ce: π Further compatibility improvements: 91.5% β 93.2% (@AbdulRashidReshamwala)
- 5e5c1ac: π Major compatibility improvement: 95.7% test coverage (@AbdulRashidReshamwala)
- 4479ea3: π Major compatibility improvements: 89.8% β 91.5% (@AbdulRashidReshamwala)
Full Changelog: v1.0.0...v1.1.0
v1.0.0
π― xpath-go v1.0.0 - Production Ready
A high-performance XPath library for Go with 100% jsdom compatibility and precise location tracking.
β¨ Key Features
- π― 100% jsdom Compatibility - Perfect matching with jsdom's XPath evaluation (76/76 tests passing)
- π Precise Location Tracking - Character-level positioning in source HTML/XML
- β‘ High Performance - Optimized evaluation engine with compiled XPath support (~2x speedup)
- π§ Production Ready - Comprehensive error handling and extensive testing
- π¦ Zero Dependencies - Pure Go implementation
π Quick Start
package main
import (
"fmt"
"log"
"github.com/reclaimprotocol/xpath-go"
)
func main() {
html := `<div id="content" class="main">Hello World</div>`
// Simple query
results, err := xpath.Query("//div[@id='content']", html)
if err != nil {
log.Fatal(err)
}
for _, result := range results {
fmt.Printf("Found: %s at position %d-%d\n",
result.TextContent, result.StartLocation, result.EndLocation)
}
}β‘ Performance Optimization
Use compiled XPath for repeated queries:
// Compile once
compiled, err := xpath.Compile("//div[@class='item']")
// Use multiple times (2x faster)
for _, doc := range documents {
results, err := compiled.Evaluate(doc)
// Process results...
}π Compatibility Status
Current jsdom compatibility: 100% (76/76 tests passing)
| Feature Category | Status | Tests |
|---|---|---|
| Basic Selection | β 100% | 12/12 |
| Attribute Queries | β 100% | 8/8 |
| Text Functions | β 100% | 15/15 |
| Position Functions | β 100% | 8/8 |
| Axes Navigation | β 100% | 18/18 |
| Complex Predicates | β 100% | 12/12 |
| String Functions | β 100% | 3/3 |
π Documentation
π§ Installation
go get github.com/reclaimprotocol/xpath-goπ§ͺ Testing
# Go tests
go test ./...
# Compatibility tests (requires Node.js)
cd tests && npm install && npm testπ Production Ready: This library is actively used in production and maintains 100% compatibility with jsdom XPath evaluation.
π€ Generated with Claude Code
Co-Authored-By: Claude noreply@anthropic.com
Full Changelog: https://github.com/reclaimprotocol/xpath-go/commits/v1.0.0