Unless you really want to use xml I'd suggest parsing the text (.csv) feed. It's always going to be smaller than xml so should be more efficient to process.
You can grab the file using a web client
using system.net
dim oWeb as new webclient
oweb.downloadfile("http://network.com/file.csv", server.mappath("/files/file.csv"))
oweb.dispose()
Once you've got the file It's an easy job to parse it vb.net . Say you have a file like this
ProductID, ProductName, Price
1, Widget, 23.99
2, Grommit , 12.99
You can parse it thus
Dim fields As String()
Dim delimiter As String = ","
Dim filename As String = Server.MapPath("~/Files/File.csv")
Using parser As New TextFieldParser(filename)
parser.SetDelimiters(delimiter)
While Not parser.EndOfData
fields = parser.ReadFields()
dim productid as string = trim(fields(0))
' grab the rest of the fields
' stick them into db
end while
end using
You'd obviously want to include code to catch bad data/missing fields etc but usually this way works out more efficient than dealing with xml files.
Quote:
Originally Posted by accelerator
Hi All
I would like to spark some discussion about Product Feed strategy for VB.net developers, in particular, whether you think I am going in the right direction. So far, I have:
- Written a VB.net script which can parse an Awin XML file sitting on my server into my MySQL database, note I only use the following Awin fields:
Advertiser
productID
productname
brand
description
deepLink
imageURL
Price
- Written an XSLT file that can take a Tradedoubler XML file and convert it into a XML file containing the above fields (i.e. a cut down version of the Awin XML file).
- My next step is to write a script that can take the Tradedoubler XML file and insert it into my MySQL database.
The eventual aim is to automate the process using some sort of batch process, and to get it working for other networks, allowing me to automatically import the various network feeds.
I would like to hear what people think of this approach. Do you think there would be other better ways to do it, in particular:
- What batch processes could I use in VB.net?
- Should I be looking at XML Web Services instead?
All comments much appreciated.
Many thanks
Accelerator
|