XMLReader is unknown

后端 未结 1 1163
别那么骄傲
别那么骄傲 2021-01-27 01:57

Following this introduction one can use the XMLReader class by importing the namespace System.Xml. In my Visual Studio project I use .NET 4.0, but System.Xml<

相关标签:
1条回答
  • 2021-01-27 02:54

    You need a reference to the System.Xml assembly (System.Xml.dll). I'm surprised it doesn't exist in the project by default, but you may have removed it.

    Note that namespaces and assemblies are different things - a using directive only imports the namespace so you can use simple names (e.g. XmlReader) without further qualification, but you still need the assembly reference as well, in the project settings.

    (As an aside, I'd personally avoid using XmlReader directly unless you really need to handle huge documents. I'd use LINQ to XML where possible - the XDocument, XElement classes etc. For those, you'll need a reference to the System.Xml.Linq assembly.)

    0 讨论(0)
提交回复
热议问题