Data Source Tutorial | Appendix B: Data Parser |
|
|
/tsra70.jpg
Only when GetTag reaches that last string does it assume its found the innermost StartTag, and so then it returns whatever lies between the StartTag and the EndTag.
With the (extensionless) image file name in hand we can now construct a local path for the image file, and restore the file's extension, using a couple of StrCat rules. Let's store the downloaded images in the C:\NOAAImages\ directory:
<ParsingRule type="StrCat" source="" result="LocalImage"> <String1>C:\NOAAImages\</String1> <String2>LocalImage</String2>
</ParsingRule>
<ParsingRule type="StrCat" source="" result="LocalImage"> <String1>LocalImage</String1> <String2>.jpg</String2>
</ParsingRule>
With the image file's local name set in the LocalImage container we can now use GetImage to download the file:
<ParsingRule type="GetImage" source="" result=""> <Url>ImageURL</Url> <LocalFilename>LocalImage</LocalFilename> </ParsingRule>
This rule downloads the file at the URL stored in the ImageURL container and saves it in the file named in the LocalImage container.
This completes the tutorial. The final definition file is shown below.
<DataSource>
<General>
<RefreshInterval>3600</RefreshInterval>
<AllowDuplicates>True</AllowDuplicates>
<Url>http://www.srh.noaa.gov/zipcity.php?inputstring=10005<
/Url>
<Database>DataFeeds.mdb</Database> <TableStructure Name="Weather"> <Field Type="Text">DayPart</Field> <Field Type="Text">Condition</Field> <Field Type="Text">Temp</Field> <Field Type="Memo">ImageURL</Field> <Field Type="Memo">LocalImage</Field> </TableStructure>
</General>
Polycom, Inc. | 189 |