Hi,
You dont need the webrequest and webresponse. Here is a simple
example.
Private Const filename As String = "http://www.politics.be/backend2.php"
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim reader As XmlTextReader = Nothing
Try
' Load the reader with the data file and ignore all white space
nodes.
reader = New XmlTextReader(filename)
reader.WhitespaceHandling = WhitespaceHandling.None
Dim bWrite As Boolean = False
' Parse the file and display each of the nodes.
While reader.Read()
Select Case reader.NodeType
Case XmlNodeType.Element
If reader.Name = "title" Then bWrite = True
'Trace.WriteLine(String.Format("<{0}>",
reader.Name))
Case XmlNodeType.Text
If bWrite Then Trace.WriteLine(reader.Value)
Case XmlNodeType.CDATA
' Trace.WriteLine(String.Format("<![CDATA[{0}]]>",
reader.Value))
Case XmlNodeType.ProcessingInstruction
'Trace.WriteLine(String.Format("<?{0} {1}?>",
reader.Name, reader.Value))
Case XmlNodeType.Comment
'Trace.WriteLine(String.Format("<!--{0}-->",
reader.Value))
Case XmlNodeType.XmlDeclaration
'Trace.WriteLine("<?xml version='1.0'?>")
Case XmlNodeType.Document
Case XmlNodeType.DocumentType
'Trace.WriteLine(String.Format("<!DOCTYPE {0}
[{1}]", reader.Name, reader.Value))
Case XmlNodeType.EntityReference
'Trace.WriteLine(reader.Name)
Case XmlNodeType.EndElement
bWrite = False
'Trace.WriteLine(String.Format("</{0}>",
reader.Name))
End Select
End While
Finally
If Not (reader Is Nothing) Then
reader.Close()
End If
End Try
End Sub
Ken
-----------------------
"LS" <in*****@invalid.com> wrote in message
news:e%****************@TK2MSFTNGP12.phx.gbl...
Hello,
I'm building an rss reader, works fine for all rss feeds, except for this
one (you can try the sample code)
The program stops on myxml.LoadXml(content)
Any ideas why this happens, I'm searching already for 2 days now.
code
-------------------------------------------------------------------------
Imports System.Xml
Imports System.Data
Imports System.Data.SqlClient
Imports System.Net
Imports System.IO
Module Module1
Sub Main()
Dim req As HttpWebRequest
Dim res As HttpWebResponse
Dim myreader As StreamReader
Dim content As String
req = HttpWebRequest.Create("http://www.politics.be/backend2.php")
req.UserAgent = "Mozilla/6.0 (MSIE 6.1; Windows NT 5.1;)"
req.MaximumAutomaticRedirections = 20
req.Timeout = 10000
req.Proxy = GlobalProxySelection.GetEmptyWebProxy()
req.KeepAlive = False
res = req.GetResponse
myreader = New StreamReader(res.GetResponseStream)
content = myreader.ReadToEnd()
myreader.Close()
myreader = Nothing
res.Close()
res = Nothing
req = Nothing
Dim myxml As New Xml.XmlDocument
Console.WriteLine(content)
myxml.LoadXml(content) 'this line gives the problem
myxml = Nothing
Console.ReadLine()
End Sub
End Module
-------------------------------------------------------------------------------------