0

I'm using a wordpress datafeed plugin to pull this Commission Junction feed. The plugin allows me to filter products by using Xpath.

<product>
  <programname>GamersGate</programname> 
  <catalogname>Gamersgate Product Catalog</catalogname> 
  <lastupdated>08/02/2013</lastupdated>
  <name>Reign: Conflict of Nations</name> 
  <keywords>reign conflict of nations, strategy</keywords>  
  <currency>USD</currency> 
  <price>6.80</price> 
  <buyurl>myurl</buyurl>  
</product>

I want to only filter in products that have been updated in the last two days.The plugin support staff told me that in order to do so, I had to change the dates to ISO format (yyyy-mm-dd), after that, the XPath would be:

/product[number(translate(lastupdated,'-','')) >= 20130801 and number(translate(lastupdated,'-','')) <= 20130802]

I have two questions about this Xpath.

Is that the best solution for filtering products based on <lastupdated>?

I was curious if it was even possible for it to automatically adjust the date range so that I don't have to manually change the Xpath every day, but they said there was no way around it. Is that totally out of the question?

choroba
  • 231,213
  • 25
  • 204
  • 289
RedGiant
  • 4,444
  • 11
  • 59
  • 146
  • Depending on your XPath engine, you should be able to use XPath variables, such as `$date_min` and `$date_max` (See for example http://saxon.sourceforge.net/saxon6.5.3/expressions.html#VariableReferences). It's possible in Python with `lxml` (http://lxml.de/xpathxslt.html#the-xpath-method) – paul trmbrth Aug 02 '13 at 12:42
  • Is that http://www.wpallimport.com/? it may not be possible to use variables – paul trmbrth Aug 02 '13 at 13:44
  • Thank you. Yes, it's wpallimport. I haven't used the Xpath they gave me yet because I'm not clear about where to "change the dates to ISO format". I just sent them an email about that. I'll also ask them if it's possible to use variables. – RedGiant Aug 02 '13 at 14:02

0 Answers0