System Error when using XmlTextReader

  • Thread starter Thread starter Rob Richardson
  • Start date Start date
R

Rob Richardson

Greetings!

I am introducing myself to VB .Net by rewriting a stock market simulation
program that I developed in VB6. The original program uses MSHTML, the
DOMDocument class and the various IHTML types to parse the contents of a web
page that contains the market information for the stocks in the simulated
portfolio.

While it seems to be possible to use the same types within VB .Net, I have
gathered that there are hoops I'd have to jump through to get them to work
in the .Net world. Also, I'd like to learn the .Net way of doing things.
It seems that the way to parse data from a web page in .Net is XML.

So, I'm trying to use the XmlTextReader object. First, I'm trying just to
get it to pull data in from a page, and then I'll figure out how to parse
it. So, I'm using the following:

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) _
Handles Button2.Click
Dim myXmlReader As XmlTextReader = _
New XmlTextReader("c:\ClevelandRails\index.htm")
Do While myXmlReader.Read()
Console.WriteLine(myXmlReader.NodeType.ToString())
Loop
End Sub

When I click Button 2, I get an XmlException thrown, and in the "Additional
Information" space, it says "System Error". The call to myXmlReader.Read()
is highlighted. Can anybody tell me why?

By the way, if anybody cares to try this with the same file, it's the home
page of http://clevelandrails.railfan.net .
Thanks very much!
Rob
 
Hi Rob,

That page is HTML, and also the path in your xmltextreader.

XML is original a dataformat that uses the same <tag> principes as HTML.

The difference is that XML has general speaking only data tags and HTML all
kind of tags.

You can access a HTML page in VB.net.

You need for that MSHTML, but it it terribible difficult to use, so be
awared.

http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/hosting/hosting.asp

You also can download a webpage document and use that as a kind of raw data,
but that seems more easy but gives mostly a lot of problems if the document
is complex.

I hope it gives you some idea's

Cor
 
Cor,

Thanks for the reply. I'm surprised that .Net doesn't have something
updated for it, but if that's what I've got to use, that's not such a bad
thing, since I've already got working code that uses it.

Rob
 
Back
Top