C#дXMLµÄ¼òµ¥Àý×Ó
Õâ¸öÀý×ÓÒª°Ñbookstore.xmlÎļþÔö¼ÓÒ»Ìõbook¼Ç¼
1 bookstore.xml
<?xml version="1.0" encoding="gb2312"?>
<bookstore>
<book genre="love" ISBN="1234123">
<title>who am i </title>
<author>who</author>
<price>999</price>
</book>
</bookstore>
2 bookstore.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
namespace toxml
{
public class ToXml
{
public static void Main(string[] args)
{
//ʵÀý»¯Ò»¸öXmlDocument¶ÔÏó
XmlDocument xmlDoc = new XmlDocument();
//ʵÀý¶ÔÏó¶ÁȡҪдÈëµÄXMLÎļþ
xmlDoc.Load("bookstore.xml");
//²éÕÒ<bookstore>
XmlNode root = xmlDoc.SelectSingleNode("bookstore");
//´´½¨Ò»¸ö<book>½Úµã
XmlElement xe1 = xmlDoc.CreateElement("book");
//ÉèÖøýڵãgenreÊôÐÔ
xe1.SetAttribute("leixing", "music");
//ÉèÖøýڵãISBNÊôÐÔ
xe1.SetAttribute("ISBN", "56756");
 
Ïà¹ØÎĵµ£º
TCPÊÇÁ¬½ÓÄ£ÐÍ£¬ÈçÏ£º
·þÎñÆ÷Á¬½Ó ·þÎñÆ÷¶Ï¿ª
↓   ......
XMLÖÐÒ»ÖÖÀ©Õ¹µÄ±ê¼ÇÓïÑÔ,Ëü¾ßÓкܺõÄÀ©Õ¹ÐÔ±ê¼Ç.±¾ÎÄͨ¹ýXMLʵÏÖ²»Í¬Êý¾Ý¿âµÄ¶¨Òå,ʵÏÖ¶ÔXMLÊý¾Ý¿âµÄ·ÃÎʺÍÒì¹¹Êý¾Ý¿âÖ®¼äµÄ»¥·Ã.
¡¡¡¡¹Ø¼ü´Ê:XML Òì¹¹Êý¾Ý¿â ÐÅÏ¢½»»» Êý¾Ý¿â·ÃÎÊ
1 ÒýÑÔ
¡¡¡¡XML(Extensible Markup Language)ËüÊÇÓÉW3C×éÖ¯ÓÚ1998Äê2Ô &nb ......
ŪÁËÁ½Ì죬ÖÕÓڰѸ´ÔÓµÄxmlÎļþµÄÊý¾Ý¸ù¾Ý×Ô¼ºµÄÒªÇó¶Á³öÀ´£¬ÏÔʾÔÚÒ³ÃæÉÏÁË¡£flexͨ¹ýHTTPService×é¼þ·¢ËÍÇëÇ󣬶ÁÈ¡xmlÎļþÖÐÊý¾Ý£¬ÓÃxmllistcollection´æ´¢xmlÖÐijһ²¿·ÖÊý¾Ý£¬²¢°ó¶¨ÔÚgridview¿Ø¼þÉÏ¡£
xml£¬xmllist£¬xmllistcollectionÖÐÖ»ÓÐxmllistcollection¾ßÓÐÐ޸ĸüÐÂÊý¾ ......
1.Ìí¼ÓÃüÃû¿Õ¼äÒýÓÃ
using System.Xml;
2.н¨xmlʵÀý
public XmlDocument objXmlDoc = new XmlDocument();
3.¼ÓÔØXmlÎĵµ
string path=Server.Mappath("demo.xml");//µÃµ½ÎĵµÂ·¾¶
objXmlDoc.Load(path);//¼ÓÔØÎĵµ
4.²éÕÒÒª½øÐвÙ×÷µÄ½áµã
objXmlDoc.SelectNodes(xpath);//µÃµ½½áµã¼¯ºÏ
objXmlDoc.SelectSingleN ......
MSXML2::IXMLDOMDocumentPtr pDoc;
MSXML2::IXMLDOMElementPtr xmlRoot ;
// ´´½¨DOMDocument¶ÔÏó
HRESULT hr = pDoc.CreateInstance(__uuidof(MSXML2::DOMDocument40));
if ( ! SUCCEEDED(hr))
{
MessageBox( " ÎÞ·¨´´½¨DOMDocument¶ÔÏó£¬Çë¼ì²é ......