【问题标题】:Stuck while XML c# parsing在 XML c# 解析时卡住
【发布时间】:2011-10-24 14:58:05
【问题描述】:

我用 C# 编写了一个代码来解析 XML 文件 (Monodevelop) 中的数据。我使用(使用 System.Xml)和(命名空间)。它在(使用 System.Xml)中出现错误。命名空间中不存在类型和命名空间名称“Xml”。我是编程新手。那么,请帮助我该怎么办?

using System;
using System.Xml;

namespace ReadXMLfromFile
{
   class sample
    {
       static void Main(string[] args)
       {
           XmlTextReader reader = new XmlTextReader ("sample.xml ");
           while (reader.Read())
           {
               switch (reader.NodeType)
            {
            case XmlNodeType.Element: // The node is an element.
                Console.Write("<" + reader.Name);
                Console.WriteLine(">");
                break;
            case XmlNodeType.Text: //Display the text in each
                element.
                    Console.WriteLine (reader.Value);
                break;
            case XmlNodeType.EndElement: //Display the end of the
                element.
                    Console.Write ("</" + reader.Name);
                Console.WriteLine(">");
                break;
            }
        }
        Console.ReadLine();
    }
}

}

【问题讨论】:

  • 向我们展示代码和示例 XML!
  • 如果您使用 Monodevelop 并针对 Mono 进行编译,则不应使用 System.Xml,而应使用 Mono 等价物。
  • 与 Monodevelop 等效的 System.Xml 是什么?

标签: c# xml parsing monodevelop


【解决方案1】:

您是否在项目文件中添加了对程序集 System.Xml 的引用(文件夹引用)?

【讨论】:

  • 是的,我已经在项目文件和调试文件夹中添加了 System.Xml。 :S
  • 我在 Dektop 中制作了项目,并将库粘贴到项目和 bin 以及调试文件夹中。
猜你喜欢
  • 1970-01-01
  • 2012-10-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-01-24
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多