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)
{
Ïà¹ØÎĵµ£º
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
namespace ConsoleApplication4
{
class Program
{
static void Main(string[] args)
{
//sqlserverÉí·ÝÑéÖ¤
//s ......
XML CDATA Îı¾
ËùÓÐ XML ÎĵµÖеÄÎı¾¾ù»á±»½âÎöÆ÷½âÎö¡£
Ö»ÓÐ CDATA Çø¶Î£¨CDATA section£©ÖеÄÎı¾»á±»½âÎöÆ÷ºöÂÔ¡£
Parsed Data
XML ½âÎöÆ÷ͨ³£»á½âÎö XML ÎĵµÖÐËùÓеÄÎı¾¡£
µ±Ä³¸ö XML ÔªËØ±»½âÎöʱ£¬Æä±êǩ֮¼äµÄÎı¾Ò²»á±»½âÎö£º
<message>´ËÎı¾Ò²»á±»½âÎö</message>
½âÎöÆ÷Ö®ËùÒÔÕâô×öÊÇÒòÎ ......
test.xml
<?xml version="1.0" encoding="utf-8" ?>
<root>
<R SecuCode="601600" Glossary="ѧITÍø²âÊÔ»ñÈ¡XML½á¹ûÏÔʾÕý³££¬¡£¡£¡£¡£¡£¡£¡£¹þ¹þ" />
<R SecuCode="600056" Glossary="²âÊÔµÚ¶þ¸ö£¬¡£¡£¡£¡£¡£¡£¡£¹þ¹þ" />
</root>
ÏÂÃæxml½âÎö ......
дUnmanaged CodeÔÚ.NETʱ´ú³ÉΪһÖֺܱ¯²ÒµÄÊ£¬µ±ÄãÐèÒª´¦ÀíXMLÎļþʱ£¬ÕâÖָоõ»á±äµÃÓÈÆäÇ¿ÁÒ¡£FCLÖеÄSystem.XML¶à¼òµ¥°¡£¬Á¬Steve Ballmer¶¼ÖªµÀÔõôÓá£
ÊÂÇé²»»á×ÜÊÇÄÇôÀíÏëµÄ£¬¼ÙÈçÄãÒªÔÚC/C++³ÌÐòÀï´¦ÀíXMLÔõô°ìÄØ£¿
Ñ¡ÔñÒ»£ºÊÐÃæÉϵÄXML lib»¹ÊÇÓм¸¸öµÄ£¬×îÓÐÃûµÄµ±È»ÊÇlibXML¡£ÎÒÒ»ÄêǰÓùý£¬ºÜ²»´í£¬ÎÒ»¹ ......
µÚÒ»ÖÖ·½Ê½--ʹÓÃMSXML2.DOMDOCUMENT.4.0
´´½¨xmldoc¶ÔÏ󣬲¢×°ÔØÒ»¸öxml
Set xmldoc = CreateObject("MSXML2.DOMDOCUMENT.4.0")
xmldoc.loadXML ("Ò»¸ö¾ßÌåµÄXMLʵÌå")
Ñ¡ÔñÐèҪɸѡµÄ½áµã
Set nodeList = xmldoc.selectNodes("//*[count(ancestor::*)= 2]") '¸ù½ÚµãµÄµÚ¶þ´úºó´ú
Set nodeList = xmldoc ......