You are here:  » Custom captures


Custom captures

Submitted by saschamcdonald on Tue, 2009-09-08 22:27 in

Hi David,

Is there a way of parsing items within the data that has been captured. - or a custom record capture? For example If the following is a record is there a way to capture the value for Country:- which in this case is UK?

 foobaarfoobarrfoobarr<STRONG>Country:</STRONG></TD><TD width="50"> </TD><TD>UK</TD>foobaarfoobarrfoobarr

Thanks,

Sascha

Submitted by support on Wed, 2009-09-09 08:42

Hello Sascha,

I presume that the content you posted is part of a field value, for example a description field within an RSS XML feed. As it is unlikely to be valid XML, it's far easier to use PHP's string handling functions to extract any information you need from an HTML block (provided that the format is consistent.

In this case; let's say that code is in the variable $record["DESCRIPTION"]; you might do something like this:

  $html = $record["DESCRIPTION"];
  $countryPos = strpos($html,"Country:");
  $countryBeg = strpos($html,"<TD>",$countryPos) + 4;
  $countryEnd = strpos($html,"</TD>",$countryBeg);
  $country = substr($html,$countryBeg,($countryEnd-$countryBeg));

It can take a little fiddling about to get right, but that's the general idea!

Hope this helps!
Cheers,
David.

Submitted by saschamcdonald on Wed, 2009-09-09 16:34

Thanks very much- great support.
s