Made an RSS feed and trying to import the XML. The description contains the fields (e.g. prodname, desc, image etc) I want to import.
How should I construct the format string?
Using this string it only takes the first htlm tag but there are more in the description field like <desc>
, <image>
.
Would it be possible to use them?
Hi Marco,
Could you re-post the link to the example feed (I'll remove before publishing your reply) and I'll look at the body within the RSS description field to see if it would be straight forward to extract...
Cheers,
David.
--
PriceTapestry.com
Hello Marco,
I have a regular expression match filter that will let you do this. Firstly, add the following code to the end of your includes/filter.php:
/*********************************************/
/* ifContainsRegExp */
/*********************************************/
$filter_names["ifContainsRegExp"] = "If Contains RegExp";
function filter_ifContainsRegExpConfigure($filter_data)
{
print "Pattern:<br />";
print "<input type='text' name='pattern' value='".widget_safe($filter_data["pattern"])."' />";
widget_errorGet("pattern");
print "Return Index: (zero based)<br />";
print "<input type='text' name='index' value='".widget_safe($filter_data["index"])."' />";
widget_errorGet("index");
}
function filter_ifContainsRegExpValidate($filter_data)
{
if (!$filter_data["pattern"])
{
widget_errorSet("pattern","required field");
}
if (!$filter_data["index"])
{
widget_errorSet("index","required field");
}
}
function filter_ifContainsRegExpExec($filter_data,$text)
{
preg_match($filter_data["pattern"],$text,$matches);
if (count($matches))
{
return $matches[intval($filter_data["index"])];
}
else
{
return $text;
}
}
Next, when registering your feed, map the DESCRIPTION field against each of the fields that are contained within it. Finally, to each of those fields you can then add an If Contains RegExp filter using, taking <image> as an example, the following Pattern:
/\b<image>(.*)<\/image>\b/
And the value 1 as the return index (0 as return index would return the full match, not just the first bracketed part)...
Hope this helps!
Cheers,
David.
--
PriceTapestry.com
Hi Marco,
The Format String for an RSS feed is
xml|RSS/CHANNEL/ITEM/
(it wouldn't auto-detect if there was only 1 item in your test feed!)
Cheers,
David.
--
PriceTapestry.com