Lifetime Licenses Are Ending Soon, Get Yours Before They're Gone
 - 
Read More
Lifetime Licenses Are Ending Soon, Get Yours Before They're Gone
 - 
Read More
Pricing

You may have seen some references on our site to annual licensing or renewals.

All plugins currently come with a lifetime license, no matter what the site says.

We’re currently running tests before we make the switch to annual pricing. Check the Discounts tab to purchase our other plugins and get a lifetime license before they’re gone.

I Understand I Have a Lifetime License
Now is your last chance to buy a lifetime license before we switch to annual pricing. Existing licenses will be unaffected.
Read More

Using XPath to Retrieve, Modify, And Filter File Elements

WP All Import uses PHP's XPath 1.0 support to allow for powerful manipulation of your data file during import. This allows you to quickly group and limit the fields that are pulled into a particular field. You can also perform simple text replacement.

Note: Most XPath statements that work directly in the SimpleXMLElement::xpath function will work in WP All Import: https://www.php.net/manual/en/simplexmlelement.xpath.php.

Note: If typing text into the import configuration with literal curly braces, the opening curly brace must be escaped with a backslash – \{something}

What is XPath?

Officially, "XPath is a language for addressing parts of an XML document...": https://www.w3.org/TR/1999/REC-xpath-19991116/

What that means in practice is that XPath is used behind the scenes in WP All Import to group and iterate through the data from your import file. Because of that, you have the opportunity to use custom XPath expressions to manipulate data during the import.

But How Do I Use It?

Say you have an import file with some image elements like this:

Use XPath to Modify Data Images Example

You could drag those elements to the Images section one by one, which is fine if you only have a few and the number of image elements remains the same:

Use XPath Drag and Drop Elements

However, what do you do if you have dozens per record, and each record could have any number of image elements? That's where the power of XPath can greatly simplify your import configuration.

Here's an XPath statement that would grab all of the images, regardless of the number in each record:

{./*[starts-with(local-name(), 'image')]}


You simply place this in the Images section:

Use XPath Starts With Local Name Image

Obtain Comma-separated List with XPath

If you have multiple nodes with similar data, you can remove the [1] part of the XPath to return a comma-separated list. For example, look at this XML:

Using XPath Example Commas WP All Import

Doing this:

{images[1]/image}

Would return the following:

image_example_1.jpg, image_example_2.jpg, image_example_3.jpg, image_example_4.jpg, image_example_5.jpg

XPath Cheat Sheet

Below are some usage examples for XPath 1.0 in WP All Import.

Access One Value Based on Another

{prop[propid = '144']/value[2]}

Access One Value Based on Another (When It’s An Attribute @):

{propertyList[1]/propertyGroup[@name="COLOR"]}

Access One Value Based on Another From Different Node

{specs/spec[./name="namegoeshere"]/value[1]}
{comments/item_3[./language="fr"]/title[1]}

Use XPath Position to Control How Many Records to Import

[FOREACH({Pic[position() <= 10]})]
{.},
[ENDFOREACH]

Additional Resources

https://developer.mozilla.org/en-US/docs/Web/XPath

https://www.w3schools.com/xml/xpath_intro.asp

Related Docs

Explains how to run PHP functions in your import when using WP All Import.

Processing and Grouping Multiple Elements with FOREACH Loops.

Learn how to use IF statements with WP All Import.

Lifetime support. Lifetime updates. Pay once.

Packages
Standalone
Import
Pro Package
$249
one-time
  • Import Pro
Import Add-Ons
  • WooCo
  • ACF
  • Gravity Forms
  • Users
  • Types
  • Export Pro
Export Add-Ons
  • WooCo
  • ACF
  • Gravity Forms
  • Users
Add to Cart
90 Day Money Back Guarantee
Import + Export Pro Package
$299
one-time
  • Import Pro
Import Add-Ons
  • WooCo
  • ACF
  • Gravity Forms
  • Users
  • Types
  • Export Pro
Export Add-Ons
  • WooCo
  • ACF
  • Gravity Forms
  • Users
Add to Cart
90 Day Money Back Guarantee
WooCommerce Import Package
$149
one-time
  • Import Pro
Import Add-Ons
  • WooCo
  • ACF
  • Gravity Forms
  • Users
  • Types
  • Export Pro
Export Add-Ons
  • WooCo
  • ACF
  • Gravity Forms
  • Users
Add to Cart
90 Day Money Back Guarantee
Import Standalone
$99
one-time
  • Import Pro
Import Add-Ons
  • WooCo
  • ACF
  • Gravity Forms
  • Users
  • Types
  • Export Pro
Export Add-Ons
  • WooCo
  • ACF
  • Gravity Forms
  • Users
Add to Cart
90 Day Money Back Guarantee
Import + Export Standalone
$169
one-time
  • Import Pro
Import Add-Ons
  • WooCo
  • ACF
  • Gravity Forms
  • Users
  • Types
  • Export Pro
Export Add-Ons
  • WooCo
  • ACF
  • Gravity Forms
  • Users
Add to Cart
90 Day Money Back Guarantee
Export Standalone
$99
one-time
  • Import Pro
Import Add-Ons
  • WooCo
  • ACF
  • Gravity Forms
  • Users
  • Types
  • Export Pro
Export Add-Ons
  • WooCo
  • ACF
  • Gravity Forms
  • Users
Add to Cart
90 Day Money Back Guarantee

Lifetime support. Lifetime updates. Pay once.

Import
Pro Package
$199
one-time
  • Import Pro
Import Add-Ons
  • WooCo
  • ACF
  • Gravity Forms
  • Users
  • Types
  • Export Pro
Export Add-Ons
  • WooCo
  • ACF
  • Gravity Forms
  • Users
Add to Cart
90 Day Money Back Guarantee
Import + Export Pro Package
$299
one-time
  • Import Pro
Import Add-Ons
  • WooCo
  • ACF
  • Gravity Forms
  • Users
  • Types
  • Export Pro
Export Add-Ons
  • WooCo
  • ACF
  • Gravity Forms
  • Users
Add to Cart
90 Day Money Back Guarantee
Export
Pro Package
$199
one-time
  • Import Pro
Import Add-Ons
  • WooCo
  • ACF
  • Gravity Forms
  • Users
  • Types
  • Export Pro
Export Add-Ons
  • WooCo
  • ACF
  • Gravity Forms
  • Users
Add to Cart
90 Day Money Back Guarantee
cross