I am new to programming and making a program in VB.Net. this program is supposed to read data table from http://www.xe.com/currencytables/?from=AUD&date=2014-09-18 and save the table in a text file. I have been researching through the web but am unable to get any answer. Would love it if someone can help me with this. Below is what i have till now
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
Dim document As New HtmlAgilityPack.HtmlDocument
Dim myHttpWebRequest = CType(WebRequest.Create("http://www.xe.com/currencytables/?from=AUD&date=2014-09-18"), HttpWebRequest)
myHttpWebRequest.UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)"
Dim streamRead = New StreamReader(CType(myHttpWebRequest.GetResponse(), HttpWebResponse).GetResponseStream)
Dim res As HttpWebResponse = myHttpWebRequest.GetResponse()
document.Load(res.GetResponseStream, True)
Dim tabletag2 As HtmlNode = document.DocumentNode.SelectSingleNode("//div[@class='ICTtableDiv']//tbody")
If tabletag2 IsNot Nothing Then
My.Computer.FileSystem.WriteAllText("C:\temp\test.txt", tabletag2.InnerHtml, False)
Else
MsgBox(Nothing)
End If
Debug.WriteLine("finished")
End Sub
This saves a text file but the data in the text file is the html code of the table. I only need table text. can anyone please help?
the Html table in the above mentioned link looks like this
<div class="ICTtableDiv">
<table id='historicalRateTbl' class='tablesorter ICTTable'>
<thead>
<tr>
<th class="ICTCurrencyCode">
Currency code
<span class="nonSortAppend">▲▼</span>
</th>
<th class="ICTCurrencyName">
Currency name
<span class="nonSortAppend">▲▼</span>
</th>
<th class="ICTRateHeader">Units per AUD</th>
<th class="ICTRateHeader">AUD per Unit</th>
</tr>
</thead>
<tbody>
<tr><td><a href='/currency/usd-us-dollar'>USD</a></td><td>US Dollar</td><td class="ICTRate">0.8982463498</td><td class="ICTRate">1.1132803381</td></tr><!-- <tr><td><a href='/currency/usd-us-dollar'>USD</a></td><td>US Dollar</td><td class="ICTRate">1.5525826958</td><td class="ICTRate">0.6440880751</td></tr> --><tr><td><a href='/currency/eur-euro'>EUR</a></td><td>Euro</td><td class="ICTRate">0.6955704202</td><td class="ICTRate">1.4376689563</td></tr><!-- <tr><td><a href='/currency/eur-euro'>EUR</a></td><td>Euro</td><td class="ICTRate">1.2973942472</td><td class="ICTRate">0.7707757316</td></tr> --><tr><td><a href='/currency/gbp-british-pound'>GBP</a></td><td>British Pound</td><td class="ICTRate">0.5485743518</td><td class="ICTRate">1.8229069527</td></tr><!-- <tr><td><a href='/currency/gbp-british-pound'>GBP</a></td><td>British Pound</td><td class="ICTRate">0.6505821652</td><td class="ICTRate">1.5370848656</td></tr> --><tr><td><a href='/currency/inr-indian-rupee'>INR</a></td><td>Indian Rupee</td><td class="ICTRate">54.5819382185</td><td class="ICTRate">0.0183210790</td></tr>
What i want is
USD US Dollar 0.8982463498 1.1132803381
for each entry in the table.