
Security News
Open Source Maintainers Feeling the Weight of the EU’s Cyber Resilience Act
The EU Cyber Resilience Act is prompting compliance requests that open source maintainers may not be obligated or equipped to handle.
Powerful CLI tool for editing SVG, HTML, and XML files using XPath and CSS selectors. Edit your structured documents directly from the command line or through a web interface.
XQR (XPath Query & Replace) is a universal file editor that treats SVG, HTML, and XML as structured data containers. Use familiar XPath expressions and CSS selectors to query, modify, and manipulate content without specialized applications.
Perfect for:
# Clone the repository
git clone https://github.com/veridock/xqr.git
cd xqr
# Install with Poetry
poetry install
# Activate the environment
poetry shell
pip install xqr
xqr examples
# Load and query a file
xqr load example.svg
xqr query "//text[@id='text1']"
# Update content
xqr set "//text[@id='text1']" "New Content"
xqr save
# The file remains loaded between commands
xqr query "//text[@id='text2']" # Works without reloading
# To load a different file
xqr load other_file.xml
For quick operations, you can directly specify the file and XPath in one command:
# Read element content
xqr example.svg//text[@id='text1']
# Update element content
xqr example.svg//text[@id='text1'] "New Value"
# Delete element content (set to empty string)
xqr example.svg//text[@id='text1'] ""
# Read from XML/HTML files
xqr config.xml//setting[@name='timeout']
xqr index.html//title "New Page Title"
# This syntax is especially useful for one-off operations and scripts.
xqr shell
📝 > load example.html
📝 > query //title
📝 > set //title "Updated Title"
📝 > save
📝 > exit
# The shell maintains state between commands automatically
xqr server --port 8080
# Open http://localhost:8080 in your browser
# The web interface shares the same state as the CLI
# Any file loaded in the web interface will be available to the CLI and vice versa
XQR maintains state between commands, making it easy to work with files across multiple operations:
# Load a file (state is saved to ~/.local/state/xqr/state.json)
xqr load example.svg
# The file remains loaded for subsequent commands
xqr query "//title"
xqr set "//version" "2.0"
xqr save
# The state persists even if you close the terminal
# Next time you run xqr, it will remember the last loaded file
xqr query "//title" # Still works with the last loaded file
# To clear the state or load a different file
xqr load different_file.html
~/.local/state/xqr/state.json
# Update chart title
xqr set "//text[@id='title']" "Q4 Sales Results"
# Change visualization colors
xqr set "//rect[@id='bar1']" "blue" --type attribute --attr fill
# Update metadata for better organization
xqr set "//metadata/description" "Updated quarterly sales chart"
# Batch update multiple SVG files
for file in charts/*.svg; do
xqr load "$file"
xqr set "//metadata/updated" "$(date)"
xqr save
done
# Update page titles across multiple pages
xqr set "//title" "New Site Title"
# Change meta descriptions for SEO
xqr set "//meta[@name='description']" "Updated SEO description" --type attribute --attr content
# Update navigation links
xqr set "//nav//a[@href='/old-page']" "/new-page" --type attribute --attr href
# CSS selector support in shell mode
xqr shell
📝 > load index.html
📝 > query #main-heading
📝 > set #main-heading "Welcome to Our New Site"
# Update configuration values
xqr set "//config/timeout" "60" --type attribute --attr value
# Modify data records
xqr set "//record[@id='1']/email" "newemail@example.com"
# Update version information
xqr set "//metadata/version" "2.0"
# Batch configuration updates
find /etc/configs -name "*.xml" -exec xqr load {} \; \
-exec xqr set "//config/debug" "false" \; \
-exec xqr save {} \;
#!/bin/bash
# Update copyright year across all HTML files
for file in **/*.html; do
echo "Processing $file..."
xqr load "$file"
xqr set "//span[@class='copyright-year']" "2025"
xqr save
done
# Update SVG chart data
#!/bin/bash
# Replace old data with new values
for chart in reports/*.svg; do
xqr load "$chart"
xqr set "//metadata/data-source" "Q1-2025-data.json"
xqr set "//text[@class='last-updated']" "$(date '+%Y-%m-%d')"
xqr save
done
# Start server
xqr server --port 8080
# Load file via API
curl -X POST http://localhost:8080/api/load \
-H "Content-Type: application/json" \
-d '{"file_path": "dashboard.svg"}'
# Query elements
curl -X POST http://localhost:8080/api/query \
-H "Content-Type: application/json" \
-d '{"query": "//text[@class=\"metric-value\"]", "type": "xpath"}'
# Update values
curl -X POST http://localhost:8080/api/update \
-H "Content-Type: application/json" \
-d '{"xpath": "//text[@class=\"revenue\"]", "type": "text", "value": "$1.2M"}'
# Save changes
curl -X POST http://localhost:8080/api/save \
-H "Content-Type: application/json" \
-d '{"output_path": "updated_dashboard.svg"}'
# Find elements by ID
//element[@id='myid']
# Find elements by attribute value
//rect[@fill='red']
# Find elements containing specific text
//text[contains(., 'Revenue')]
# Find elements by position
//record[position()=1]
# Find parent elements with specific children
//record[email='john@example.com']
# Complex queries with multiple conditions
//svg//text[@font-size='16' and contains(@class, 'title')]
# By ID
#main-title
# By class
.navigation-item
# By attribute
input[type='text']
# Descendant selectors
div.content p
# Pseudo-selectors
li:first-child
# Complex selectors
nav.primary ul.menu li a[href^="/products"]
xqr/
├── pyproject.toml # Poetry configuration
├── README.md # This file
├── Makefile # Development automation
├── xqr/ # Main package
│ ├── __init__.py # Package initialization
│ ├── core.py # Core FileEditor class
│ ├── cli.py # Command-line interface
│ ├── server.py # HTTP server
│ └── examples.py # Example file generator
└── tests/ # Test suite
├── __init__.py
├── test_core.py
├── test_cli.py
└── test_server.py
# Clone repository
git clone https://github.com/veridock/xqr.git
cd xqr
# Install with development dependencies
poetry install
# Create example files and run tests
make dev-setup
# Run full development cycle
make dev
make help # Show all available commands
make install # Install package
make test # Run test suite
make test-cov # Run tests with coverage
make format # Format code with black
make lint # Run linting
make examples # Create example files
make demo-svg # Run SVG demo
make run-server # Start web server
make run-shell # Start interactive shell
# Run all tests
poetry run pytest
# Run with coverage
poetry run pytest --cov=xqr --cov-report=html
# Run specific test file
poetry run pytest tests/test_core.py -v
# Update configuration across multiple environments
for env in dev staging prod; do
xqr load "config-${env}.xml"
xqr set "//database/host" "db-${env}.company.com"
xqr set "//cache/ttl" "3600"
xqr save
done
# Update copyright notices across all HTML files
find . -name "*.html" -exec xqr load {} \; \
-exec xqr set "//footer//span[@class='year']" "2025" \; \
-exec xqr save {} \;
# Extract and transform data from XML files
xqr shell << EOF
load sales-data.xml
list //record[sales>10000]
set //record[sales>10000]/status "high-performer"
save processed-sales.xml
exit
EOF
# Update chart data and metadata
xqr load quarterly-chart.svg
xqr set "//text[@class='chart-title']" "Q1 2025 Results"
xqr set "//metadata/generated" "$(date)"
xqr setattr "//rect[@class='revenue-bar']" height "250"
xqr save
git checkout -b feature/xpath-improvements
)make test
)make format
)git commit -am 'Add XPath improvements'
)git push origin feature/xpath-improvements
)This project is licensed under the MIT License - see the LICENSE file for details.
Traditional approaches require different tools for each format:
XQR provides a unified interface using standard web technologies:
Perfect for:
E-commerce: Update product prices across thousands of XML files
find products/ -name "*.xml" -exec xqr set "//price[@currency='USD']" "$(calc_new_price {})" \;
Documentation: Update version numbers in all HTML docs
xqr set "//meta[@name='version']" "v2.1.0" --type attribute --attr content
Analytics: Update dashboard charts with new data
xqr set "//svg//text[@class='metric']" "$REVENUE_METRIC"
XQR - Making structured data editing simple, fast, and scriptable.
FAQs
Universal CLI tool for editing SVG, HTML, and XML files using XPath and CSS selectors
We found that xqr demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The EU Cyber Resilience Act is prompting compliance requests that open source maintainers may not be obligated or equipped to handle.
Security News
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.