从xml读取游戏配置信息或保存
/*
* 主要作用;
* 从xml读取游戏配置信息或保存
*/
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Forms;
using System.IO;
using System.Xml;
using System.Reflection;
namespace Game
{
class Config
{
Keys up;
Keys down;
Keys left;
Keys right;
int time;
public int Time
{
get { return time; }
set { time = value; }
}
public Keys Up
{
get { return up; }
set { up = value; }
}
public Keys Down
{
get { return down; }
set { down = value; }
}
public Keys Left
{
get { return left; }
set { left = value; }
}
public Keys Right
{
get { return right; }
set { right = value; }
}
//读取游戏配置信息
public void GetXml()
{
XmlTextReader reader;
if (File.Exists("Config.xml"))
{
reader = new XmlTextReader("Config.xml");
}
else
{
Assembly asm = Assembly.GetExecutingAssembly();
Stream s = asm.GetManifestResourceStream("Game.Config.xml");
reader = new XmlTextReader(s);
}
try
{
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element)
{
if (reader.Name == "up")
{
up = (Keys)Convert.ToInt32(reader.ReadElementString().Trim());
}
else if (reader.Name == "down")
{
down = (Keys)Convert.ToInt32(reader.ReadElementString().Trim());
相关文档:
最近做的一个项目中运用 xml 数据岛技术,所以把数据岛方面的知识总结一下。
XML 数据岛 ( data islands )就是被 html 页面引用或者包含的 xml 数据,是从 IE5 开始引入的一项技术。可以通过 xml 标签很轻松将数据岛插入到 html 文档中。那么怎么访问 xml 数据岛的数据呢,很简单,通过 xml 的 id 。在页 ......
问题描述:
jboss应用服务器,使用spring
无法启动服务,错误日志:
[org.apache.xerces.jaxp.DocumentBuilderFactoryImpl@155d3a3] does not
support XML Schema. Are you running on Java 1.4 or below with Apache
Crimson? Upgrade to Apache Xerces (or Java 1.5) for full XSD ......
public static IList<News> GetAllNews()
{
XmlDocument xdoc = new XmlDocument();
xdoc.Load("你读取的地址:例如 ......
如何在VC环境下编写程序读取XML文件?清提供源代码.谢谢.
#import <msxml3.dll> named_guids //导入动态库,装了IE5就有
using namespace MSXML2; //引用命名空间,一般可以把命名空间理解成类和接口的集合,呵呵,对不对我也不知道了
#include <vector>
using na ......