XML如何序列化成字符串
来源:互联网 发布:淘宝商品详情页制作 编辑:程序博客网 时间:2024/04/29 21:56
XML如何序列化成字符串
-----------------------------
using System;
using System.Xml.Serialization;
namespace BLL.FrameWork
{
/// <summary>
/// ActionMapping对Struts-config.xml的映射 的摘要说明。
/// 2005-12-11 PM 17:15 Modify HHD.
/// </summary>
[XmlRoot("action-mappings")]
public class ActionMapping
{
[XmlElement("action")]
public Action[] Actions;
}
public class Action
{
[XmlAttribute("name")]
public string Name = "";
[XmlAttribute("classname")]
public string ClassName = "";
[XmlAttribute("path")]
public string Path = "";
[XmlAttribute("input")]
public string Input = "";
[XmlAttribute("validate",DataType="boolean")]
public bool Validate = false;
[XmlAttribute("istransaction",DataType="boolean")]
public bool IsTransAction = false;
[XmlElement("forward")]
public Forward[] Forwords;
}
public class Forward
{
[XmlAttribute("name")]
public string Name = "";
[XmlAttribute("path")]
public string Path = "";
}
}
调用
。。。
Hashtable StrutsData = (Hashtable)HttpContext.Current.Cache["StrutsData"];
if(StrutsData==null)
{
StrutsData = new Hashtable();
string xmlpath = HttpContext.Current.Server.MapPath(ConfigurationSettings.AppSettings["strutsconfig"]);
XmlSerializer xs = new XmlSerializer(typeof(ActionMapping));
FileStream fs = new FileStream(xmlpath,FileMode.Open);
ActionMapping actionmapping = (ActionMapping)xs.Deserialize(fs);
fs.Close();
int actionmappinglength = actionmapping.Actions.Length;
for(i=0;i<actionmappinglength;i++)
{
Hashtable temp = new Hashtable();
temp.Add("ClassName",actionmapping.Actions[i].ClassName);
temp.Add("Path",actionmapping.Actions[i].Path);
temp.Add("Input",actionmapping.Actions[i].Input);
temp.Add("Validate",actionmapping.Actions[i].Validate);
temp.Add("IsTransAction",actionmapping.Actions[i].IsTransAction);
temp.Add("Forwords",actionmapping.Actions[i].Forwords);
StrutsData.Add(Convert.ToString(actionmapping.Actions[i].Name),temp);
}
HttpContext.Current.Cache.Insert("StrutsData",StrutsData);
}
。。。
- XML如何序列化成字符串
- [Unity 笔记] unity中如何将Object序列化成xml字符串并保存
- C# XML Serialization序列化成字符串含有65279
- boost 序列化成 xml文件
- boost 序列化成 xml文件
- C#序列化成XML注意事项
- 将XML序列化成对象
- object序列化成json字符串
- DataTable序列化成Json字符串
- android parcelable序列化成字符串
- java类序列化成xml 方法
- 将类序列化成xml文件
- 将对象序列化成XML文件
- java类序列化成xml 方法
- C#基于DataContract序列化成XML格式
- js对象序列化成json字符串
- Java 序列化学习 —— Object序列化成字符串
- Object序列化成一个字符串(JSON的序列化)
- [胡言乱语 & 随口说说]我有不祥的预感
- courage
- Java学习:EJB的专用术语解释
- 上周技术关注:AJAX good practices
- 在 Ubuntu Linux 上安装 Java 和 Eclipse
- XML如何序列化成字符串
- 电子签名
- 用委托改写一个经典函数指针问题
- Null Net,空
- 自考
- 开始php之旅
- SourceMonitor: 代码重构的小工具,大用场
- 第一次使用blog
- 一直的我