Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xml - '=' is an unexpected token, the expected token is ';'

Tags:

c#

xml

i'm using this code to read a xml file

string xmlcontents = System.IO.File.ReadAllText("the xml path");
xml.LoadXml(xmlcontents);

when i execute this code it gives me this error

System.Xml.XmlException: ''=' is an unexpected token. The expected token is ';'

here is the xml line with the error

<SubMenu name="Assassins Creed Origins" picture="https://image.ibb.co/gqeqpd/image.jpg" Torrent="http://rarbg.to/download.php?id=hzvlmyb&f=The.Endless.2017.1080p.BluRay.H264.AAC-RARBG-[rarbg.to].torrent" />

the error is in the Torrent attribute, its because the link contains & and replacing it with &amp; will fix the problem, but if i do that the link will be incorrect, how to fix this problem?

Thanks.

like image 757
kurdish gaming Avatar asked Jun 20 '18 18:06

kurdish gaming


People also ask

What is the difference between <> and expected token?

The data contains URL and read that data and bind to table. '>' is an unexpected token. The expected token is '"' or '''. Line 1, position 50. Any Body can Please share solution to me.

What is the expected token for the exception''on pagedata?

' ' is an unexpected token. The expected token is ';'. Line 1257, position 66. at System.Xml.XmlTextReaderImpl.Throw (Exception e) pageData is a custom object from another system, that is spitting out a datastream.

What is the expected token on line 1544?

The expected token is ';'. Line 1544, position 46.) Details: [Binary] The issue is apparently with this line in the XML (and thereafter)

What is the expected token for the torrent error?

The expected token is ';' the error is in the Torrent attribute, its because the link contains & and replacing it with & will fix the problem, but if i do that the link will be incorrect, how to fix this problem? Thanks.


1 Answers

As it stands that is invalid XML. You will need to encode the & as &amp;. When you read it out from your XML document, it will be just &.

like image 195
Daniel A. White Avatar answered Oct 16 '22 17:10

Daniel A. White