XML解析错误-C#

XML解析错误-C#,c#,xml,visual-studio-2010,xmldocument,C#,Xml,Visual Studio 2010,Xmldocument,我的代码在第7行位置32处出现XML解析错误,我不确定原因 精确错误转储 5/1/2010 10:21:42 AM System.Xml.XmlException: An error occurred while parsing EntityName. Line 7, position 32. at System.Xml.XmlTextReaderImpl.Throw(Exception e) at System.Xml.XmlTextReaderImpl.Throw(String

我的代码在第7行位置32处出现XML解析错误,我不确定原因

精确错误转储

5/1/2010 10:21:42 AM
System.Xml.XmlException: An error occurred while parsing EntityName. Line 7, position 32.
   at System.Xml.XmlTextReaderImpl.Throw(Exception e)
   at System.Xml.XmlTextReaderImpl.Throw(String res, Int32 lineNo, Int32 linePos)
   at System.Xml.XmlTextReaderImpl.HandleEntityReference(Boolean isInAttributeValue, EntityExpandType expandType, Int32& charRefEndPos)
   at System.Xml.XmlTextReaderImpl.ParseAttributeValueSlow(Int32 curPos, Char quoteChar, NodeData attr)
   at System.Xml.XmlTextReaderImpl.ParseAttributes()
   at System.Xml.XmlTextReaderImpl.ParseElement()
   at System.Xml.XmlTextReaderImpl.ParseElementContent()
   at System.Xml.XmlTextReaderImpl.Read()
   at System.Xml.XmlLoader.LoadNode(Boolean skipOverWhitespace)
   at System.Xml.XmlLoader.LoadDocSequence(XmlDocument parentDoc)
   at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)
   at System.Xml.XmlDocument.Load(XmlReader reader)
   at System.Xml.XmlDocument.Load(String filename)
   at Lookoa.LoadingPackages.LoadingPackages_Load(Object sender, EventArgs e) in C:\Users\Administrator\Documents\Visual Studio 2010\Projects\Lookoa\Lookoa\LoadingPackages.cs:line 30
Xml文件,请注意,这只是一个示例,因为我希望在开始填充此存储库之前程序能够正常工作

<repo>
<Packages>
    <TheFirstPackage id="00001" longname="Mozilla Firefox" appver="3.6.3" pkgver="0.01" description="Mozilla Firefox is a free and open source web browser descended from the Mozilla Application Suite and managed by Mozilla Corporation. A Net Applications statistic  put Firefox at 24.52% of the recorded usage share of web browsers as of March 2010[update], making it the second most popular browser in terms of current use worldwide after Microsoft's Internet Explorer." cat="WWW" rlsdate="4/8/10" pkgloc="http://google.com"/>
</Packages>
<categories>
    <WWW longname="World Wide Web" description="Software that's focus is communication or primarily uses the web for any particular reason."> </WWW>
    <Fun longname="Entertainment & Other" description="Music Players, Video Players, Games, or anything that doesn't fit in any of the other categories."> </Fun>
    <Work longname="Productivity" description="Application's commonly used for occupational needs or, stuff you work on"> </Work>
    <Advanced longname="System & Security" description="Applications that protect the computer from malware, clean the computer, and other utilities."> </Advanced>
</categories>
</repo>

Messagebox.Show()只是为了确保它得到正确的结果

符号在XML中有特殊的含义。您需要更改:

Entertainment & Other
要使用a替换此字符,请执行以下操作:

Entertainment &amp; Other

这同样适用于
System&Security

您的xml“&”中有无效字符


更新:将其替换为
&

,并确保在使用时正确转义任何其他字符,以防在一天内滑落……或在属性值的某处出现“appr”。
Entertainment &amp; Other