You are here:  » Custom xPath


Custom xPath

Submitted by Tom on Wed, 2018-10-31 14:37 in

Hi,

Most of the productfeeds we'are using right now are filled with products we don't want to track. Based on the feed we would like to "filter" them based on the xPath. Is it possible to do so? The product-feed (data) is as follow (only one product for now):

<products>
<product ID="112515">
<name>Winter Slagharen: een dag vol avontuur (2 p.)</name>
<price currency="EUR">1.00</price>
<URL>...</URL>
<images>...</images>
<description>...</description>
<categories>
<category path="Dagje weg">Dagje weg</category>
</categories>
<properties>
<property name="categoryPath">
<value>pretparken</value>
</property>
<property name="subcategories">
<value>pretparken</value>
</property>
<property name="tags">
<value>attractiepark slagharen</value>
</property>
</properties>
<variations/>
</product>
</products>

It should be possible (it's valid xPath) to get this product based on the following xPath

//PRODUCTS/PRODUCT/PROPERTIES/PROPERTY[@name="categoryPath"]/VALUE[text()="pretparken"]/../../../

Is it possible within PriceTapestry to do so?

Kind regards.
Tom

Submitted by support on Wed, 2018-10-31 14:53

Hello Tom and welcome to the forum!

There isn't XPATH support specifically within the script that would enable selection on that basis (the format string for a feed whilst using path style notation isn't actually an XPATH expression).

However, what you could do in this situation is;

1) Add a new Custom Field called "properties".

2) Add the Extract XML Duplicates filter from this thread to your installation.

3) Add a new Extract XML Duplicates filter to the properties field for your feed and on the configuration page for the filter enter the Base Field Name as follows;

PROPERTIES/PROPERTY/VALUE

4) Add a new Drop Record If Not filter to the properties field for your feed and on the configuration page for the filter enter the text to match if you want a record to be imported e.g.

pretparken

At the next import, only records with the comma separated field properties created by the Extract XML Duplicates filter containing the text pretparken would be imported.

If you require more control, for example if the keyword would match a longer word causing ambiguity you can use the RegExp versions of the Drop Record filters. In this example, to match pretparken as a whole word only you would use;

/\bpretparken\b/

(in this case "/" are the delimiters, and \b matches beginning of line, end of line or any other word boundary character e.g. space)

Hope this helps!

Cheers,
David.
--
PriceTapestry.com