asp.net ¶ÁÈ¡XmlÎļþ²¢½øÐÐDropDownListÊý¾Ý°ó¶¨
<asp:DropDownList ID="compactType" runat="server" AutoCallBack="True" Width="153px"> </asp:DropDownList>
<?xml version="1.0" encoding="utf-8" ?>
<roots>
<root>
<id>1</id>
<Culture>³õÖÐÒÔÏÂ</Culture>
</root>
<root>
<id>2</id>
<Culture>³õÖÐ</Culture>
</root>
<root>
<id>3</id>
<Culture>ÖÐר</Culture>
</root>
<root>
<id>4</id>
<Culture>¸ßÖÐ</Culture>
</root>
<root>
<id>5</id>
<Culture>´óר</Culture>
</root>
<root>
<id>6</id>
<Culture>±¾¿Æ</Culture>
</root>
</roots>
/// <summary>
/// ¶ÁÈ¡xmlÎļþ,ÓÃÊý¾ÝÌî³äDropDownList,½øÐаó¶¨
/// </summary>
/// <param name="path">xmlÎļþ·¾¶</param>
/// <param name="dp">Òª½øÐа󶨵ÄDropDownListÃû³Æ</param>
/// <param name="id">DropDownListÒªÏÔʾµÄÎı¾(xmlÎļþµÄÒ»¸ö½Úµã)</param>
/// <param name="val">DropDownListÒªÏÔʾµÄÖµ(xmlÎļþµÄÒ»¸ö½Úµã)</param>
public void ReadXml(string path,DropDownList dp,string id,string val)
{
DataSet ds = new DataSet();
ds.ReadXml(path);
dp.DataSource = ds;
dp.DataTextField = id ;
dp.DataValueField = val;
dp.DataBind();
}
SecurityFactory sf = new SecurityFactory();
//xmlÎļþ·¾¶
string path2 = Server.MapPath("./xml/XMLFile2.xml");
sf.ReadXml(path2, this.compactType, "id", "val");
Ïà¹ØÎĵµ£º
Ò»¡¢¼òµ¥½éÉÜ
using System.Xml;
//³õʼ»¯Ò»¸öxmlʵÀý
XmlDocument xml=new XmlDocument();
//µ¼ÈëÖ¸¶¨xmlÎļþ
xml.Load(path);
xml.Load(HttpContext.Current.Server.MapPath("~/file/bookstore.xml"));
//Ö¸¶¨Ò»¸ö½Úµã
XmlNode root=xml.SelectSingleNode("/root");
//»ñÈ¡½ÚµãÏÂËùÓÐÖ±½Ó×Ó½Úµã
XmlNodeList ch ......
1.route.xmlÎļþÄÚÈÝ
<?xml version="1.0" encoding="GBK"?>
<root>
<route id="1111">
<id>111</id>
<name>ËÄ´¨</name>
<path>www.baidu.com/hehe.html</path>
</route>
</root>
2.test.html´úÂë
<html>
<body>
<script> ......
Ò³ÃæÊä³ö»º´æ×÷Ϊ×î¼òµ¥µÄ»º´æÐÎʽ£¬Êä³ö»º´æÖ»ÊÇÔÚÄÚ´æÖб£ÁôΪÏìÓ¦ÇëÇó¶ø·¢Ë굀 HTML µÄ¸±±¾¡£ÆäºóÔÙÓÐÇëÇóʱ½«Ìṩ»º´æµÄÊä³ö£¬Ö±µ½»º´æµ½ÆÚ£¬ÕâÑù£¬ÐÔÄÜÓпÉÄܵõ½ºÜ´óµÄÌá¸ß£¨È¡¾öÓÚÐèÒª¶àÉÙ¿ªÏúÀ´´´½¨ÔʼҳÃæÊä³ö - ·¢ËÍ»º´æµÄÊä³ö×ÜÊǺܿ죬²¢ÇұȽ ......
1 ʹÓñê×¼HTMLÀ´½øÐÐͼƬÉÏ´«
ǰ̨´úÂ룺
<body>
<form id="form1" runat="server">
<div>
<table>
&nbs ......