Click here to Skip to main content
14,428,725 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hello Everyone

I use the below code to get rss feed

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
An error occurred while parsing EntityName. Line 1, position 104.



How to solve this error?
Posted
Updated 4-Dec-15 12:51pm
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

Rate this:
Please Sign up or sign in to vote.

Solution 1

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.
   
v4

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100