Hi, thanks for looking at my project. I need a PHP script which will read a tab-delineated text flatfile and generate an XML sitemap, formatted for Google Video. All needed specifications are included here.
The source database is a text file, in which records are separated by a carriage return and fields are separated by tabs.
Here is the guide to the fields:
http://www.autopages.com/track/mapping.txt
This is what we need the result file to look like (## numbers below correspond to the field number of the source record … so for example, ##2## would be the text from field 2 of the record):
<urlset xmlns=”http://www.sitemaps.org/schemas/sitemap/0.9″
xmlns:video=”http://www.google.com/schemas/sitemap-video/1.1″>
<url>
<loc>http://www.autopages.com/videolistings/##9##.html</loc>
<video:video>
<video:content_loc>http://www.autopages.com/mp4/##9##.mp4</video:content_loc>
<video:thumbnail_loc>http://www.autopages.com/listingthumbnails/##18##**see note**</video:thumbnail_loc>
<video:title>##2## ##3## ##4## in ##8##, ##15##</video:title>
<video:description>For more info on this vehicle, call us at ##7##.
See the full listing at http://www.AutoPages.com/##32##. ##5##. $##6##.</video:description>
<video:tag>##3##</video:tag>
<video:tag>##4##</video:tag>
<video:tag>##8##</video:tag>
<video:category>Autos for Sale</video:category>
<video:family_friendly>yes</video:family_friendly>
<video:duration>60</video:duration>
</video:video>
</url>
</urlset>
So, here is an example source record:
v 2008 Jeep Wrangler X 4×4 Loaded with options. Ask for ford used sales when you call. we have been in business since 1938. great financing rates available! Power door locks, power windows, alloy wheels, cruise control, rear defroster, console, cd player, am/fm radio, bucket seats, cloth seats, warranty, a/c. Stop by before it’s gone. 24941 1-800-784-1334 Tacoma twf_W5805 F W5805 TWF Titus Will Ford 3606 S Sprague Avenue WA 98409 fordusedATtituswill.com http://www.autobase.com/photos/00640/0432/04326449_001.jpg http://www.autobase.com/photos/00640/0432/04326449_001.jpg http://www.autobase.com/photos/00640/0432/04326449_004.jpg http://www.autobase.com/photos/00640/0432/04326449_004.jpg http://www.autobase.com/photos/00640/0432/04326449_003.jpg http://www.autobase.com/photos/00640/0432/04326449_003.jpg http://www.autobase.com/photos/00640/0432/04326449_006.jpg http://www.autobase.com/photos/00640/0432/04326449_006.jpg http://www.autobase.com/photos/00640/0432/04326449_007.jpg http://www.autobase.com/photos/00640/0432/04326449_007.jpg http://www.autobase.com/photos/00640/0432/04326449_002.jpg http://www.autobase.com/photos/00640/0432/04326449_002.jpg http://www.autobase.com/photos/00640/0432/04326449_005.jpg http://www.autobase.com/photos/00640/0432/04326449_005.jpg 83149 http://www.autobase.com/photos/00640/0432/04326449_008.jpg
And that record would look like this in the destination XML file:
<urlset xmlns=”http://www.sitemaps.org/schemas/sitemap/0.9″
xmlns:video=”http://www.google.com/schemas/sitemap-video/1.1″>
<url>
<loc>http://www.autopages.com/videolistings/twf_W5805.html</loc>
<video:video>
<video:content_loc>http://www.autopages.com/mp4/twf_W5805.mp4</video:content_loc>
<video:thumbnail_loc>http://www.autopages.com/listingthumbnails/04326449_001.jpg</video:thumbnail_loc>
<video:title>2008 Jeep Wrangler X in Tacoma, WA</video:title>
<video:description>For more info on this vehicle, call us at 1-800-784-1334.
See the full listing at http://www.AutoPages.com/83149. Loaded with options. Ask for ford used sales when you call. we have been in business since 1938. great financing rates available! Power door locks, power windows, alloy wheels, cruise control, rear defroster, console, cd player, am/fm radio, bucket seats, cloth seats, warranty, a/c. Stop by before it’s gone. $24,941.</video:description>
<video:tag>Jeep</video:tag>
<video:tag>Wrangler X</video:tag>
<video:tag>Tacoma</video:tag>
<video:category>Autos for Sale</video:category>
<video:family_friendly>yes</video:family_friendly>
<video:duration>60</video:duration>
</video:video>
</url>
</urlset>
Beyond this simple mapping, there are only a few added functions the script needs to have:
1.) It should skip all records in the source database which do not have “F” in field 10.
2.) The script should have an “exclude” array in its settings area. (i.e., “$exclude = array(“ASF”,”CPK”,”KOR”,”BTT”,”BTA”,”BTN”,”RTH”,”RLP”,”RLC”,”RLV”,”AAP”,”GIL”,”LMM”,”AOT”,”PSU”);”
Any record whose field 12 contains one of the values in this array should be skipped.
3.) For the “<video:thumbnail_loc>” value, the script should write “http://www.autopages.com/listingthumbnails/” followed by the FILENAME of the URL in record field 18. In other words, if record field 18 contains, for example: “http://www.autobase.com/photos/00640/0432/04326449_001.jpg”, the script should replace the URL with the one autopages.com on above and append the filename (04326449_001.jpg) to it.
So, as you can see above, the resulting line should be:
<video:thumbnail_loc>http://www.autopages.com/listingthumbnails/04326449_001.jpg</video:thumbnail_loc>
The result XML file created by this script will be checked for validation.
That’s it! Please let me know if you have any questions and I look forward to working with you.