C#Windows窗体应用程序中的XML [英] XML in C# Windows Form Application

查看:236
本文介绍了C#Windows窗体应用程序中的XML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有此XML代码,我想以一种形式使用它,但我必须做什么?

这是我要使用的代码Flash:

< coffeecupvideoadd>
mainwidth ="300"
mainheight ="251"
版本="3.1"
bkfillclr ="0xC0C0C0"
movie ="[002]新增-intro.flv"
moviex ="2"
moviey ="2"
moview ="297"
movieh ="247"
mlink ="
mframe ="_ self"
transition ="none"
bkborder ="t"
bkborderwidth ="2"
bkbordercolor ="0x000000"
bordercolor ="0x000000"
disableclicktoactiveprompt ="false" loop ="t"
startmuted ="f"
borderw ="1"
bktile ="f"
>
< button
x ="298"
y ="16"
w ="11"
h ="224"
label ="Sound Off"
ulabel ="Sound On"
visible ="f"
></button>



I have this XML codes and i want to use it in one of my forms what i have to do?

this are the codes flash which i wanna use:

<coffeecupvideoadd>
mainwidth="300"
mainheight="251"
version="3.1"
bkfillclr="0xC0C0C0"
movie="[002] New - intro.flv"
moviex="2"
moviey="2"
moview="297"
movieh="247"
mlink=""
mframe="_self"
transition="none"
bkborder="t"
bkborderwidth="2"
bkbordercolor="0x000000"
bordercolor="0x000000"
disableclicktoactiveprompt="false" loop="t"
startmuted="f"
borderw="1"
bktile="f"
>
<button
x="298"
y="16"
w="11"
h="224"
label="Sound Off"
ulabel="Sound On"
visible="f"
></button>



推荐答案

猜测,您可能需要从 ^ ]类.除了很难说.
At a guess you probably need to start with the XmlReader[^] class. Beyond that it''s difficult to say.


.NET中至少有三种方法可以生成和解析XML.这是我的简短概述:

There are at least three approaches in .NET to generating and parsing XML. Here is my short overview:


  1. 使用System.Xml.XmlDocument类.它实现了DOM接口;如果文档太大,则这种方法最简单,也足够好.
    请参见 http://msdn.microsoft.com/en-us/library/system.xml.xmlwriter.aspx [ http://msdn.microsoft.com/en-us/library/system.xml.xmlreader.aspx [ http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx [http://msdn.microsoft.com/en-us/library/bb387063.aspx [

  1. Use System.Xml.XmlDocument class. It implements DOM interface; this way is the easiest and good enough if the size if the document is not too big.
    See http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx[^].
  2. Use the classes System.Xml.XmlTextWriter and System.Xml.XmlTextReader; this is the fastest way of reading, especially is you need to skip some data.
    See http://msdn.microsoft.com/en-us/library/system.xml.xmlwriter.aspx[^], http://msdn.microsoft.com/en-us/library/system.xml.xmlreader.aspx[^].
  3. Use the class System.Xml.Linq.XDocument; this is the most adequate way similar to that of XmlDocument, supporting LINQ to XML Programming.
    See http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx[^], http://msdn.microsoft.com/en-us/library/bb387063.aspx[^].



此外,我不确定您是否需要直接使用XML.您可能需要使用序列化,尤其是数据合同.请参阅:
http://msdn.microsoft.com/en-us/library/ms731073.aspx [ ^ ],
http://msdn.microsoft.com/en-us/library/ms733127.aspx [ ^ ].

—SA



Besides, I''m not sure you need to work with XML directly. You might need to use serialization, in particular, Data Contract. Please see:
http://msdn.microsoft.com/en-us/library/ms731073.aspx[^],
http://msdn.microsoft.com/en-us/library/ms733127.aspx[^].

—SA


这篇关于C#Windows窗体应用程序中的XML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆