Filters & XPath
Filter your import data and use XPath expressions for XML files
Overview
Filters allow you to exclude or include specific rows from your import based on conditions. This is useful for importing only certain products, excluding test data, or filtering by specific criteria.
XPath is used specifically for XML files to target specific nodes in the XML structure. This helps when your XML has nested elements or when you need to import only a subset of the data.
XPath for XML Files
What is XPath?
XPath (XML Path Language) is a query language for selecting nodes from an XML document. In PrimeLink, XPath helps you target specific elements in your XML file.
When to Use XPath
Use XPath when:
- Your XML has nested structures and you need to target specific nodes
- You want to import only a subset of products from a larger XML file
- The XML structure is complex and auto-detection doesn't work correctly
XPath Examples
Basic XPath Expressions
/products/product- Select all product elements directly under products root//product- Select all product elements anywhere in the document/catalog/items/item- Select items nested in catalog → items/products/product[@status='active']- Select only products with status="active" attribute
Auto-Detection
PrimeLink can automatically detect XML root elements:
- Click Detect Roots button
- PrimeLink will scan your XML and suggest root paths
- Select the appropriate path from the suggestions
- Or manually enter your XPath expression
XPath Best Practices
- Start simple: Try auto-detection first before writing custom XPath
- Test your XPath: Check the preview to ensure it selects the right nodes
- Use attributes: XPath can filter by element attributes (e.g.,
[@type='product']) - Be specific: More specific XPath expressions are more reliable
Filter Builder
Creating Filters
Filters allow you to include or exclude rows based on field values:
- In Step 4, find the Filter Builder section
- Click Add Filter or Add Condition
- Select the field to filter by
- Choose an operator (equals, contains, greater than, etc.)
- Enter the value to match
- Add more conditions and choose AND/OR logic
Available Operators
Comparison Operators
- = (Equals) - Exact match
- != (Not Equals) - Not equal to value
- > (Greater Than) - Numeric comparison
- < (Less Than) - Numeric comparison
- >= (Greater Than or Equal) - Numeric comparison
- <= (Less Than or Equal) - Numeric comparison
Text Operators
- contains - Field contains the value (case-insensitive)
- not_contains - Field does not contain the value
List Operators
- in - Field value is in the list (comma-separated values)
- not_in - Field value is not in the list
Pattern Operators
- regex - Field matches regular expression pattern
- not_regex - Field does not match regular expression pattern
Filter Examples
Example 1: Price Filter
Goal: Import only products with price greater than $50
- Field:
price - Operator:
> - Value:
50
Example 2: Category Filter
Goal: Import only products in specific categories
- Field:
category - Operator:
in - Value:
Electronics, Computers, Phones
Example 3: Stock Status Filter
Goal: Import only in-stock products
- Field:
stock_status - Operator:
= - Value:
instock
Example 4: Exclude Test Products
Goal: Exclude products with "TEST" in the title
- Field:
title - Operator:
not_contains - Value:
TEST
Example 5: SKU Pattern Filter
Goal: Import only products with SKU starting with "PROD-"
- Field:
sku - Operator:
regex - Value:
^PROD-
Multiple Conditions
AND Logic
When using AND logic, all conditions must be true for a row to be included:
- Example: Price > 100 AND Stock Status = "instock"
- Only products that meet BOTH conditions will be imported
OR Logic
When using OR logic, any condition being true will include the row:
- Example: Category = "Electronics" OR Category = "Computers"
- Products matching EITHER condition will be imported
Combining AND and OR
You can create complex filters by combining AND and OR logic:
- Group conditions logically
- Example: (Price > 100 OR Featured = "yes") AND Stock Status = "instock"
Saving and Loading Filter Presets
Saving Filter Presets
You can save filter configurations for reuse:
- Build your filter conditions
- Click Save Preset or similar button
- Enter a name for the preset
- The preset will be saved for future use
Loading Filter Presets
To reuse a saved filter preset:
- Click Load Preset or open the presets dropdown
- Select the preset you want to use
- The filter conditions will be loaded automatically
- Modify if needed or use as-is
Preview with Filters
Live Preview
The data preview in Step 4 updates automatically when you change filters:
- As you add or modify filters, the preview table updates
- You can see exactly which rows will be imported
- Verify your filters are working correctly before proceeding
Row Count
The preview shows how many rows match your filters:
- Total rows in file vs filtered rows
- Use this to verify your filters are working as expected
- Adjust filters if the count doesn't match your expectations
Best Practices
- Test filters first: Use the preview to verify filters work correctly
- Start simple: Begin with one condition, then add more if needed
- Use presets: Save commonly used filters for quick access
- Check data types: Ensure numeric comparisons use numeric fields
- Case sensitivity: Text operators are case-insensitive by default
- Regex patterns: Test regex patterns carefully before using in production
- XPath validation: Verify XPath expressions select the correct nodes
Next Steps
Learn how to map filtered data to WooCommerce fields
Learn More →Complete guide to the import process
Learn More →Set up automatic imports with filters
Learn More →