Skip to content

C# console app reading from xml file and download action

Marcel Monsanto

Asked May 7, 2007, 3:18 AM EDT1 answer
Share
LinkedInX

I am novice to programming. I am building a c# console app. that must read several urls ending with .csv and download or copy those csv file's to the location given in the xml file.
For so far i've got the app working that the content of the file is printed on the screen, but can someone help to get the app to do what i want?
Thnx in advance

using System;
using System.IO;
using System.Xml;
using System.Net;
namespace Book
{/// <summary>/// Summary description for Class1./// </summary>
class Class1{/// <summary>/// /// </summary>
[STAThread]
static void Main(string[] args)
{XmlTextReader reader = null;
reader = new XmlTextReader("WTZI.xml");
while (reader.Read())
{if (reader.NodeType == XmlNodeType.Element)
{if(reader.LocalName.Equals("locatie"))
{Console.Write("{0}",reader.ReadString());}
if(reader.LocalName.Equals("bestemming"))
{Console.Write("{0}",reader.ReadString());}}}}}}

Content of the xml file
=====================
<?xml version="1.0" encoding="utf-8" ?>
<bestanden>
<bestand>
<locatie>http://www.bouwcollege.nl/Exports/CIBG/GRIP_Doelgroepen.csv</locatie>;
<bestemming>c:\temp\WTZI\Doelgroepen.csv</bestemming>
</bestand>
<bestand>
<locatie>http://www.bouwcollege.nl/Exports/CIBG/GRIP_Instellingen.csv</locatie>;
<bestemming>c:\temp\WTZI\Instellingen.csv</bestemming>
</bestand>
<bestand>
<locatie>http://www.bouwcollege.nl/Exports/CIBG/GRIP_Toelatingen.csv</locatie>;
<bestemming>c:\temp\WTZI\Toelatingen.csv</bestemming>
</bestand>
<bestand>
<locatie>http://www.bouwcollege.nl/Exports/CIBG/GRIP_Toelatingfuncties.csv</locatie>;
<bestemming>c:\temp\WTZI\Toelatingfuncties.csv</bestemming>
</bestand>
<bestand>
<locatie>http://www.bouwcollege.nl/Exports/CIBG/GRIP_Zorgkantoren.csv</locatie>;
<bestemming>c:\temp\WTZI\Zorgkantoren.csv</bestemming>
</bestand> </bestanden>

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.