c#:Dataset读取XML文件动态生成菜单
Step 1:Form1 上添加一个ToolStripContainer控件
Step2:实现代码
private void Form2_Load(object sender, EventArgs e)
{
CMenuEx menu = new CMenuEx();
string sPath = "D:\\Menu.xml";//xml的内容
if (menu.FileExit())
{
menu.LoadAllMenu(sPath, toolStripContainer1);
}
else
{ MessageBox.Show("XML文件加载失败!"); }
}
/// <summary>
/// 菜单读取类
/// </summary>
public class CMenuEx
{
private string _Path;
/// <summary>
/// 设置XML配置文件路径
/// </summary>
public string Path
{
get { return _Path; }
set { _Path = value; }
}
/// <summary>
/// 判断文件是否存在
/// </summary>
/// <returns>文件是否存在</returns>
public bool FileExit()
{
if (File.Exists(_Path))
{ return true; }
else return false;
}
/// <summary>
/// 加载菜单
/// </summary>
/// <param name="menuStrip">母菜单对象</param>
public void LoadAllMenu(string sXmlPath, ToolStripContainer pToolStripContainer)
{
DataSet ds = new DataSet();
ds.ReadXml(sXmlPath, XmlReadMode.Auto);
相关文档:
是否厌倦了用xml文件来做Magento的页面布局,是的话来试试下面这种方式,把布局代码写到controller 里面
public function mycoolAction()
{
/* ... Some code ...*/
$update = $this->getLayout()->getUpdate();
/* ... Some code ...*/
$this->addActionLayoutHandles();
/* ... Some code ...*/
......
已知有一个XML文件(bookstore.xml)如下:
<?xml version="1.0" encoding="gb2312"?>
<bookstore>
<book genre="fantasy" ISBN="2-3631-4">
<title>Oberon's Legacy</title>
<author>Corets, Eva</author>
&nb ......
Unix时间戳最小单位是秒,开始时间为格林威治标准时间1970-01-01 00:00:00
ConvertIntDateTime方法的基本思路是通过获取本地时区表示Unixk开始时间,加上Unix时间值(即过去的秒数).
ConvertDateTimeInt方法的基本思路是通过刻度数差,再把刻度数转换为秒数,当然要说明的是,我这里返回的是double类型,意义上并非是真 ......
Loading XML data using ActionScript 3.0
By Blue_Chi | Flash CS3 | ActionScript 3.0 | Beginner
Using XML is one of the best ways for structuring external content in a logical format that is easy to understand, process, and update. This tutorial will teach you the basics on how to load and process X ......
using System.Text.RegularExpressions;
string ohtml = this.TextBox1.Text;
System.Text.RegularExpressions.MatchCollection m;
//提取字符串的图片
......