C#ÏÔʾXMLÔªËØÄÚÈݵļòµ¥Àý×Ó
½ÓÉÏһƪ
ÏÔʾËùÓнáµãµÄÄÚÈÝ
1 ÔxmlÎļþ bookstore.xml
<?xml version="1.0" encoding="gb2312"?>
<bookstore>
<book ISBN="1234123">
<title>who am i </title>
<author>who</author>
<price>999</price>
</book>
<book>
</book>
</bookstore>
2 program.cs
using System;
using System.Xml;
namespace ReadXml
{
class Class1
{
static void Main(string[] args)
{
//ʵÀý»¯Ò»¸öXmlDocument¶ÔÏó
XmlDocument xmlDoc = new XmlDocument();
//ʵÀý¶ÔÏó¶ÁȡҪдÈëµÄXMLÎļþ
xmlDoc.Load("bookstore.xml");
XmlNode xn = xmlDoc.SelectSingleNode("bookstore");
XmlNodeList xnl = xn.ChildNodes;
foreach (XmlNode xnf in xnl)
{
XmlElement xe = (XmlElement)xnf;
//¸ÃÊôÐÔûÓУ¬²»ÏÔʾ£¬µ«²»»á±¨´í
Console.WriteLine(xe.GetAttribute("genre"));
//ÏÔʾÊôÐÔÖµ
&nb
Ïà¹ØÎĵµ£º
ÒÔÏÂΪһÌìµÄ»ù±¾Ñ§Ï°Çé¿ö£¬°üÀ¨Ñ§Ï°ºÍ¸´Ï°£¬Ä£Ê½²¿·ÖǰǰºóºóÒ²¿´Á˺ܶàÁË£¬µ«ÊÇһֱûÄܼá³Ö¿´Í꣬ϣÍûÕâ´Î¿ÉÒÔ¼á³ÖÏÂÈ¥¡£
ģʽ²¿·ÖÎÒûÓÐÖ±½ÓÈ¥¿´±È½Ï¾µäµÄ¡¶javaÓëģʽ¡·£¬ÕâÊéÌ«ºñÈÝÒ×ÈÃÎÒ¼á³Ö²»ÏÂÈ¥£¬¶øÊDzÉÓÃÁ˳̽ÜдµÄ¡¶´ó»°Éè¼ÆÄ£Ê½¡·£¬
ÕâÊéдµÄºÜÓÐÒâ˼£¬Ò²ºÜÈÝÒ×Àí½â¡£Ï£ÍûÕâÑùµÄÊé¿ÉÒÔ¶àЩ¡£ºÇºÇ£¬µ±È»µÈ¿´ ......
´ó¼Ò¶¼ÖªµÀÔÚSQL ServerÖÐÀûÓà FOR XML PATH Óï¾äÄܹ»°Ñ²éѯµÄÊý¾ÝÉú³ÉXMLÊý¾Ý£¬ÏÂÃæÊÇËüµÄһЩӦÓÃʾÀý¡£
DECLARE @TempTable table(UserID int , UserName nvarchar(50));
insert into @TempTable (UserID,UserName) values (1,'a')
insert into @TempTable (UserID,UserName) values (2,'b')
select UserID, ......
Ò»£ºÉè¼ÆÄ£Ê½²¿·Ö
״̬ģʽ£¨state£©
״̬ģʽÀàËÆÓÚÒ»ÖÖ¼òµ¥µÄ¹¤×÷Á÷£¬ÓÃÀ´°Ñ´óÁ¿µÄÅжϷÖÖ§½øÐвð·Ö£¬¸øÃ¿Ò»ÖÖÅжÏÔö¼ÓÒ»¸ö״̬£¬Èç¹û²»Âú×ã¸ÃÅжϿÉÒÔ½øÐÐ״̬ת»»£¬ÖªµÀÓöµ½Âú×ãÌõ¼þΪֹ
ÕâÑù×öµÄºÃ´¦¾ÍÊÇ£¬µ±ÐèÒªÔö¼ÓÅжϵÄʱºò£¬²»ÐèÒª¸Ä±äÒѾ´æÔڵĴúÂë¡£Ö»ÐèÒªÔö¼ÓÅжϵÄÀ࣬ÔʼÅжÏÀàÖÐÔö¼ÓеÄ״̬ת»»¡£
Ê ......
½ÓÉÏһƪ¡¶C#дXMLµÄ¼òµ¥Àý×Ó¡·
Õâ¸öÀý×ÓÒªÐÞ¸ÄXMLÎļþÖнáµãµÄÊôÐԺͺÍÔªËØµÄÎı¾
1 ÔxmlÎļþ bookstore.xml
<?xml version="1.0" encoding="gb2312"?>
<bookstore>
<book genre="love" ISBN="1234123">
<title>who am i </title>
&l ......
½ÓÉÏһƪ
ɾ³ýÔgenreÊôÐÔ£¬É¾³ýleixing=loveµÄËùÓнáµã¡£
1 ÔxmlÎļþ bookstore.xml
<?xml version="1.0" encoding="gb2312"?>
<bookstore>
<book genre="love" ISBN="1234123">
<title>who am i </title>
<author>who</aut ......