Click here to Skip to main content
15,881,715 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Everyone

I use the below code to get rss feed

C#
protected void Page_Load(object sender, EventArgs e)
{

    string x = "xml url string";

        XmlTextReader reader = new XmlTextReader(x);
        DataSet ds = new DataSet();
        ds.ReadXml(reader);
        DataList1.DataSource = ds.Tables["item"];
        DataList1.DataBind();}


but i get this error
C#
An error occurred while parsing EntityName. Line 1, position 104.



How to solve this error?
Posted
Updated 4-Dec-15 11:51am
v2
Comments
Snesh Prajapati 4-Dec-15 18:30pm    
I have updated below answer with more precise data and links. Hope That will be more helpful. Thanks.

1 solution

Hi Amosh,

As per the code given by you, variable x is supposed to contain valid XML which is not there. Once you put a valid XML there, hopefully your code will work.

Valid XML is something like as given at
http://stackoverflow.com/questions/4601139/how-to-read-a-xml-string-into-xmltextreader-type[^]:
string x = "<TestDataXml><DataName>testing</DataName></TestDataXml>" ;

So correct that line and for more n valid XML please have a look at:
http://stackoverflow.com/questions/730133/invalid-characters-in-xml[^]

http://stackoverflow.com/questions/86292/how-to-check-for-valid-xml-in-string-input-before-calling-loadxml[^]

A resolution for similar issue also given here:
http://stackoverflow.com/questions/23541910/an-error-occurred-while-parsing-entityname-line1-position-844[^]

Thanks.
 
Share this answer
 
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900