Sunday, 5 April 2015

XMLException was unhandled 'var' is an unexpected token. The expected token is '='



I am trying to read xml node values from a xml file. But when I do it throws this exception:



System.Xml.XmlException: 'src' is an unexpected token. The expected token is '='. Line 29, position 19. at System.Xml.XmlTextReaderImpl.Throw(String res, String[] args) at System.Xml.XmlTextReaderImpl.ParseAttributes() at System.Xml.XmlTextReaderImpl.ParseElement() at System.Xml.XmlTextReaderImpl.ParseElementContent() at System.Xml.XmlLoader.LoadNode(Boolean skipOverWhitespace) at System.Xml.XmlLoader.LoadDocSequence(XmlDocument parentDoc) at System.Xml.XmlDocument.Load(XmlReader reader) at System.Xml.XmlDocument.Load(String filename) at ToolkitM9.RVersion.Window_Loaded(Object sender, RoutedEventArgs e) in f:\Development\ToolkitM9\ToolkitM9\RVersion.xaml.cs:line 48



This is my code:



XmlDocument xDoc = new XmlDocument();
xDoc.Load("Version.xml");

XmlNodeList name = xDoc.GetElementsByTagName("Name");
XmlNodeList ver = xDoc.GetElementsByTagName("Version");
XmlNodeList notes = xDoc.GetElementsByTagName("Notes");
XmlNodeList openSite = xDoc.GetElementsByTagName("openSite");
XmlNodeList link = xDoc.GetElementsByTagName("Link");

MessageBox.Show(
"Name: " + name[0].InnerText + "\n" +
"Version: " + ver[0].InnerText + "\n" +
"Notes: " + notes[0].InnerText + "\n" +
"Open Link? " + openSite[0].InnerText + "\n" +
"Link: " + link[0].InnerText + "\n"


This is my XML file:



<Recovery>
<Name>TWRP</Name>
<Version>2.5.0.3</Version>
<Notes>There are some bugs remaining in this build. See here..</Notes>
<openSite>true</openSite>
<Link>http://ift.tt/1GeyB4e;
</Recovery>


Thanks for any assistance! :)


No comments:

Post a Comment