XMLÔö\ɾ¡¢¸Ä¡¢²é¼òµ¥²Ù×÷
protected void Page_Load(object sender, EventArgs e)
{
lblValue.Text = string.Format("{0:N}", 2500000);
lblValue.Text = string.Format("{0:C3}", 2);
// ¼ÓÔØÊ±²»»º´æÊý¾Ý
Response.Cache.SetNoStore();
if (!IsPostBack)
{
// ³õʼ»¯Ò³ÃæÏÔʾ
ShowXml();
}
}
// ³õʼ»¯Ò³ÃæÏÔʾ
private void ShowXml()
{
// »ñÈ¡xmlÊý¾Ý
string url = Server.MapPath("user.xml");
StreamReader sr = new StreamReader(url, System.Text.Encoding.GetEncoding("GB2312"));
// ²Ù×÷xmlÎĵµ
XmlDataDocument xmlDataDocument = new XmlDataDocument();
// ½«¶ÁÈ¡µÄ×Ö½ÚÁ÷±£´æµ½DataSetÖÐ
xmlDataDocument.DataSet.ReadXml(sr);
this.DataGrid1.DataSource = xmlDataDocument.DataSet.Tables[0].DefaultView;
// ¶¨ÒåÏÔʾID
this.DataGrid1.DataKeyField = "username";
this.DataGrid1.DataBind();
xmlDataDocument = null;
sr.Close();
}
protected override void OnInit(EventArgs e)
{
Ïà¹ØÎĵµ£º
¼ÓÔØÍⲿµÄXMLÎļþ£¬ÎļþÃûÊÇ1.xml;
<?xml version="1.0" encoding="utf-8"?>
<website>
<name a="Ãû×Ö1">ÖÜС´¨1</name>
<name a="Ãû×Ö2">ÖÜС´¨2</name>
<name a="Ãû×Ö3">ÖÜС´¨3</name>
<name a="Ãû×Ö4">ÖÜС´¨4</name>
<name a="Ãû×Ö5"> ......
try { //Internet Explorer
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async="false";
xmlDoc.loadXML(data);
} catch(e) { //Other Browsers
parser=new DOMParser();
xmlDoc=parser.parsefromString(data,"text/xml");
} ......
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Xml;
private XmlDo ......
µ±Ò³ÃæÔØÈëʱ£¬»áÖ´ÐÐλÓÚ body ²¿·ÖµÄ JavaScript¡£
µ±±»µ÷ÓÃʱ£¬Î»ÓÚ head ²¿·ÖµÄ JavaScript ²Å»á±»Ö´ÐС£
2006Äê1ÔÂ14ÈÕ£¬John Resig ÔÚBarCampNYCÉϵÚÒ»´Î·¢²¼ÁËjQuery¡£
JSON(JavaScript Object Notation) ÊÇÒ»ÖÖÇáÁ¿¼¶µÄÊý¾Ý½»»»¸ñʽ¡£Ò×ÓÚÈËÔĶÁºÍ±àд¡£Í¬Ê±Ò²Ò×ÓÚ»úÆ÷½âÎöºÍÉú³É¡£Ëü»ùÓÚJavaScript£¨St ......
XML(eXtensible Markup Language)ÊÇÍòÎ¬ÍøÁªÃË(World Wide Web Consortium W3C)¶¨ÒåµÄÒ»ÖÖ¿ÉÀ©Õ¹±êÖ¾ÓïÑÔ¡£
¿ÉÀ©Õ¹ÐÔÖ¸ÔÊÐíÓû§°´ÕÕXML¹æÔò×Ô¶¨Òå±ê¼Ç(tags ±êÇ©)¡£
Ç¿ÏÇáËɱí´ï¶à²ã½á¹¹µÄÊý¾Ý£»¿ÉÀ©Õ¹¡£
Óŵ㣺ƽ̨Î޹أ¬ÓïÑÔÎ޹ء£Éè¼ÆÄ¿±êÊÇÃèÊöÊý¾Ý²¢¼¯ÖÐÓÚÊý¾ÝµÄÄÚÈÝ£¬ÓëÏÔʾ·ÖÀë¡£
ÌáÐÑ£º² ......