XMLµÄ¼òµ¥¶ÁÈ¡ÓëдÈë
ÒÑÖªÓÐÒ»¸ö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>
<price>5.95</price>
</book>
</bookstore>
1¡¢Íù<bookstore>½ÚµãÖвåÈëÒ»¸ö<book>½Úµã£º
XmlDocument xmlDoc=new XmlDocument();
xmlDoc.Load("bookstore.xml");
XmlNode root=xmlDoc.SelectSingleNode("bookstore");//²éÕÒ<bookstore>
XmlElement xe1=xmlDoc.CreateElement("book");//´´½¨Ò»¸ö<book>½Úµã
xe1.SetAttribute("genre","ÀîÔÞºì");//ÉèÖøýڵãgenreÊôÐÔ
xe1.SetAttribute("ISBN","2-3631-4");//ÉèÖøýڵãISBNÊôÐÔ
XmlElement xesub1=xmlDoc.CreateElement("title");
xesub1.InnerText="CS´ÓÈëÃŵ½¾«Í¨";//ÉèÖÃÎı¾½Úµã
xe1.AppendChild(xesub1);//Ìí¼Óµ½<book>½ÚµãÖÐ
XmlElement xesub2=xmlDoc.CreateElement("author");
xesub2.InnerText="ºò½Ý";
xe1.AppendChild(xesub2);
XmlElement xesub3=xmlDoc.CreateElement("price");
xesub3.InnerText="58.3";
xe1.AppendChild(xesub3);
root.AppendChild(xe1);//Ìí¼Óµ½<bookstore>½ÚµãÖÐ
xmlDoc.Save("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>
<price>5.95</price>
</book>
<book genre="ÀîÔÞºì" ISBN="2-3631-4">
<title>CS´ÓÈëÃŵ½¾«Í¨</title>
<author>ºò½Ý</author>
<price>58.3</price>
</book>
</bookstore>
2¡¢Ð޸Ľڵ㣺½«genreÊôÐÔֵΪ“ÀîÔ޺쓵ĽڵãµÄgenreÖµ¸ÄΪ“updateÀîÔ޺씣¬½«¸Ã½ÚµãµÄ×Ó½Úµã<author>µÄÎı¾ÐÞ¸ÄΪ“ÑÇʤ”¡£
XmlNodeList nodeList=xmlDoc.SelectSingleNode("bookstore").ChildNodes;//»ñÈ¡bookstore½ÚµãµÄËùÓÐ×Ó½Úµã
foreach(XmlNode xn in nodeList)//±éÀúËùÓÐ×Ó½Úµã
{
XmlElement xe=(XmlElement)xn;//½«×Ó½ÚµãÀàÐÍת»»Îª
Ïà¹ØÎĵµ£º
ͨ¹ýAsp.net(C#)Ó¦ÓóÌÐò¶ÁÈ¡±¾µØÉÏ´«µÄExcleÎļþ,´æ·Åµ½DataSetÖÐ,ͨ¹ýDataSetÖеķ½·¨Ö±½ÓÉú³ÉXMLÎļþ.
C# Code
if (this.FileUpload1.PostedFile != null)
{
string filename = this.FileUpl ......
using System;
using System.Data;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Xml;
using FilmOnLine.Model;
namespace FilmOnLine.DAL
{
public static class FilmService
{
/// <summary>
/// Ìí¼ÓµçÓ°
/// </summary ......
¾³£»áÓõ½xmlÎļþ£¬ÄÚÈݼÓÔØ£¬ Èç¹ûʹÓÃlinq xmlÊ÷¼ÓÔØ£¬ÐèҪͨ¹ýXElementÀ࣬һÖÖ·½Ê½ÊÇÒÔ×Ö·û´®µÄÐÎʽ¼ÓÔØ£¬ÁíÍâÒ»ÖÖ·½Ê½ÊÇÒÔÎļþÐÎʽ¼ÓÔØ¡£ 1.ÒÔ×Ö·û´®ÐÎʽ¼ÓÔØ¡£ ÔÚXElementÀàÖУ¬Í¨¹ý¾²Ì¬µÄParse()·½·¨ ......
XMLÊDZ»Éè¼ÆΪ´æ´¢¡¢´«ÊäÒÔ¼°½»»»Êý¾ÝµÄ¡£XML²»ÊDZ»Éè¼ÆΪÓÃÀ´ÏÔʾÊý¾ÝµÄ¡£
¡¡¡¡XML¿ÉÒÔ½«HTMLÓëÊý¾Ý·ÖÀë
¡¡¡¡Í¨¹ýʹÓÃXML£¬ÄúµÄÊý¾Ý¿É´æ´¢ÓÚHTMLÖ®Íâ¡£
¡¡¡¡µ±ÎÒÃÇʹÓÃHTMLÀ´ÏÔʾÊý¾Ýʱ£¬Êý¾Ý´æ´¢ÓÚHTMLÖС£Í¨¹ýʹÓÃXML£¬Êý¾Ý¿ÉÒÔ±»´æ´¢ÔÚµ¥¶ÀµÄXMLÎļþÖС£ÕâÑù×öµÄ»°£¬Äú¾Í¿ÉÒÔ°Ñ×¢ÒâÁ¦¼¯ÖÐÔÚʹÓÃHTML½øÐÐÊý¾Ý²¼¾Öº ......
ʲôÊÇ XML£¿
¡¡¡¡¿ÉÀ©Õ¹±ê¼ÇÓïÑÔ (XML) ÊÇ Web ÉϵÄÊý¾ÝͨÓÃÓïÑÔ¡£Ëüʹ¿ª·¢ÈËÔ±Äܹ»½«½á¹¹»¯Êý¾Ý£¬´ÓÐí¶à²»Í¬µÄÓ¦ÓóÌÐò´«µÝµ½×ÀÃ棬½øÐб¾µØ¼ÆËãºÍÑÝʾ¡£XML ÔÊÐíΪÌض¨Ó¦ÓóÌÐò´´½¨Î¨Ò»µÄÊý¾Ý¸ñʽ¡£Ëü»¹ÊÇÔÚ·þÎñÆ÷Ö®¼ä´«Êä½á¹¹»¯Êý¾ÝµÄÀíÏë¸ñʽ¡£
¡¡¡¡Ê²Ã´ÊÇ MSXML£¿
¡¡¡¡MSXML ÊÇÌṩºËÐÄ XML ·þÎñµÄ Microsoft Èí ......