开发者

Program skips code after trying to parse XML in VB.NET

I'm trying to parse some XML (html) I downloaded using WebRequest.Create() and then read it. However after loading the XML file using LoadXml(string), anything else I execute doesn't work. Setting a breakpoint on anything afterwards doesn't work and it doesn't break.

I tried catching exception but none are occurring, so I'm not sure what the problem is.

Here is my code:

Dim reader As StreamReader = New StreamReader(HTTPResponse.GetResponseStream())
        Dim xDoc As XmlDocument = New XmlDocument()
        xDoc.LoadXml(reader.ReadToEnd())
        Dim omfg As String = xDoc.ChildNodes().Item(0).Inn开发者_开发百科erText()
        Dim name As XmlNodeList = xDoc.GetElementsByTagName("div")
        Dim jj As Integer = name.Count
        For i As Integer = 0 To name.Count - 1
            MessageBox.Show(name.Item(i).InnerText)
        Next i

Anything after the "xDoc.LoadXml(reader.ReadToEnd())" doesn't execute.. Any ideas on this? My XML does have some whitespace at the beginning, I don't know if that is causing the problem...


Just a guess, but it's throwing an exception because the html you download isn't well-formed xml, and you have a high-level try catch block hiding the error from you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜