Watch out for those two lines that got wrapped; both pertain to Me.lblStatus.Text and should be only one line each.
Main Topics
Browse All TopicsHello,
I have the following error:
Invalid character in the given encoding. Line 25, position 114.
I am using Asp.net Vb.net with the code below:
<div>
<asp:GridView ID="GridView1" runat="server" DataSourceID="XmlDataSourc
</asp:GridView>
<asp:XmlDataSource ID="XmlDataSource1" runat="server"
DataFile="http://www.meteo
</asp:XmlDataSource>
</div>
I read here that this might be because of encoding to utf-8.
I changed the webconfig as follows:
<globalization
fileEncoding="utf-8"
requestEncoding="utf-8"
responseEncoding="utf-8"
/>
But still get the same error. Please help
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
ajitha75, Great tip! I was able to read but I still had binaries in lieu of the french accents.
I used this fonction:
Public Function ProcessRSSItem(ByVal rssURL As String) As String
'Definition de la valeur par défaut de retour
ProcessRSSItem = "Serveur injoignable!"
'test de la connexion au serveur xml
Dim instance As New Devices.Network
'Dim address As Uri
Dim returnValue As Boolean = True
'Try
' returnValue = instance.Ping(url)
'Catch ex As Exception
' MsgBox(ex.Message)
'End Try
'Tentative de résolution de l'affichage aléatoire des flux RSS
'Dim returnValue As Boolean = False
'Try
' returnValue = instance.Ping(url)
'Catch ex As Exception
' MsgBox(ex.Message)
'End Try
If returnValue Then
Try
ProcessRSSItem = ""
Dim myRequest As WebRequest = System.Net.WebRequest.Crea
Dim myResponse As WebResponse = myRequest.GetResponse()
Dim rssStream As Stream = myResponse.GetResponseStre
Dim rssDoc As New XmlDocument()
rssDoc.Load(rssStream)
Dim rssItems As XmlNodeList = rssDoc.SelectNodes("rss/ch
Dim title As String = ""
Dim link As String = ""
Dim description As String = ""
Dim i As Integer
For i = 0 To rssItems.Count - 1
Dim rssDetail As XmlNode
rssDetail = rssItems.Item(i).SelectSin
If rssDetail.Equals(Nothing) = False Then
title = rssDetail.InnerText
Else
title = ""
End If
rssDetail = rssItems.Item(i).SelectSin
If rssDetail.Equals(Nothing) = False Then
link = rssDetail.InnerText
Else
link = ""
End If
rssDetail = rssItems.Item(i).SelectSin
If rssDetail.Equals(Nothing) = False Then
description = rssDetail.InnerText
Else
description = ""
End If
ProcessRSSItem += "
" + title + "
"
ProcessRSSItem += description + "
"
Next
Catch ex As Exception
ProcessRSSItem += "Le serveur est injoignable. Veuillez vérifier votre connexion internet !"
End Try
End If
End Function
And it worked great.
Business Accounts
Answer for Membership
by: azarc3Posted on 2008-07-19 at 07:28:08ID: 22042561
Is there a reason why you've got the data file URL in the DataFile attribute twice?
> inal text]]></description>
---------- ---------- ---------- ----
ount > 0 AndAlso Request.QueryString.AllKey s.Contains ("feed") Then
ring.Item( "feed"))
th(".") & "\App_Data\xml_file_4330.x ml") ruction e
---------- ---------- ---------- ----
The XML in the URL you're targeting doesn't play nice with .NET... you'll see what I mean in my example below. Regardless, the main problem is that the source of this data is sticking "&" characters in the <description> element of the <item> sets... which the .NET XML parser doesn't like. I'm not sure if that's only .NET either.
Anyway, if you want to use these feeds you're going to have to figure out a way to replace the
<description></description
tags with
<description><![CDATA[orig
to allow illegal characters to pass through.
You may want to consider looking for some type of .NET RSS component that specifically handles situations like this if you don't want to tackle the necessary coding yourself...
Here's my example code; I got it to populate the gridview after I had massaged the incoming XML data appropriately.
This code is written targeting the NET v2.0 framework, with some tried and true v1.1 techniques for dealing with XML. Also, I wrote this in code-behind; you may need to make a few slight adjustments if you are doing this inline.
--------------------------
'need these to get at a few necessary objects
Imports System.IO
Imports System.Xml
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'This "If..Then" condition allows me to use this same functionality with more than one data source
If Request.QueryString.Keys.C
'This label helps me to see that the page actually refreshed.
Me.lblStatus.Text = "It's ALIVE!
" & Date.Now.ToString
'Once formatted, bind the data to the control
Me.GridView1.DataSource = GetRSSFeed(Request.QuerySt
Me.GridView1.DataBind()
Else
'This label helps me to see that the page actually refreshed.
Me.lblStatus.Text = "* Please provide a valid feed URL *
" & Date.Now.ToString
End If
End Sub
Function GetRSSFeed(ByVal strURL As String) As DataTable
Dim sb As New StringBuilder
'Get the XML data
'@@@ Ideally, this is what we want to use...
' but the following line DOES NOT WORK because of "&" symbols in data
'Using reader As XmlTextReader = New XmlTextReader(strURL)
'@@@ We have to use this one instead to at least prove we can get at the data...
Using reader As XmlTextReader = New XmlTextReader(Server.MapPa
While reader.Read()
Select Case reader.NodeType
Case XmlNodeType.Element
sb.AppendLine("<" & reader.Name & ">")
Case XmlNodeType.Text
sb.Append(reader.Value)
Case XmlNodeType.CDATA
sb.Append("<![CDATA[" & reader.Value & "]]>")
Case XmlNodeType.ProcessingInst
sb.AppendLine("<?" & reader.Name & " " & reader.Value & "?>")
Case XmlNodeType.Comment
sb.AppendLine("<!--" & reader.Value & "-->")
Case XmlNodeType.XmlDeclaration
sb.AppendLine("<?xml version='1.0'?>")
Case XmlNodeType.Document
Case XmlNodeType.DocumentType
sb.AppendLine("<!DOCTYPE " & reader.Name & " [" & reader.Value & "]")
Case XmlNodeType.EntityReferenc
sb.AppendLine(reader.Name)
Case XmlNodeType.EndElement
sb.AppendLine("</" & reader.Name & ">")
End Select
End While
End Using
'return a new DataSet
Dim ds As DataSet = New DataSet()
ds.ReadXml(New StringReader(sb.ToString))
Return ds.Tables(2)
End Function
--------------------------
FINAL COMMENTS:
If you have have any influence over how your target XML files are generated, as them to use CDATA on any fields that MIGHT contain characters that XML considers illegal, such as "&".
HTH.
Necessary for demo; rename extension to .xml and put in your /App_Data folder.