LINQ to XML ѧϰ±Ê¼Ç
LINQ to XML ¿ÉÒÔ¿´×÷ÊÇÒ»¸ö “better DOM” ±à³ÌÄ£ÐÍ£¬¿ÉÒÔºÍ System.Xml.dll ³ÌÐò¼¯Öеĺܶà³ÉÔ±½»»¥¡£
Ò»¡¢ÃüÃû¿Õ¼ä
System.Xml.Linq.dll ³ÌÐò¼¯¶¨ÒåÁËÈý¸öÃüÃû¿Õ¼ä£ºSystem.Xml.Linq, System.Xml.Schema ºÍ System.Xml.XPath
×îºËÐĵÄÊÇ System.Xml.Linq£¬ ¶¨ÒåÁ˶ÔÓ¦ XML Îĵµ¸ö·½ÃæµÄºÜ¶àÀàÐÍ
Member of System.Xml.Linq
Meaning in Life
XAttribute
Represents an XML attribute on a given XML element
XComment
Represents an XML comment
XDeclaration
Represents the opening declaration of an XML document
XDocument
Represents the entirety of an XML document
XElement
Represents a given element within an XML document
XName/XNamespace
Provide a very simple manner to define and reference XML namespaces
¶þ¡¢±à³Ì·½Ê½´´½¨XMLÎĵµ
ÒÔǰµÄ .NET XML±à³ÌÄ£ÐÍÐèҪʹÓúܶàÈß³¤µÄ DOM API£¬¶ø LINQ to XML ÔòÍêÈ«¿ÉÒÔÓÃÓë DOM Î޹صķ½Ê½Óë XML Îĵµ½»»¥¡£ÕâÑù²»µ«´ó´ó¼õÉÙÁË´úÂëÐУ¬¶øÇÒÕâÖÖ±à³ÌÄ£ÐÍ¿ÉÒÔÖ±½ÓÓ³Éäµ½¸ñʽÁ¼ºÃµÄXMLÎĵµ½á¹¹¡£
static void CreateFunctionalXmlElement()
{
// A "functional" approach to build an
// XML element in memory.
XElement inventory =
new XElement("Inventory",
new XElement("Car", new XAttribute("ID", "1"),
new XElement("Color", "Green"),
new XElement("Make", "BMW"),
new XElement("PetName", "Stan")
)
);
// Call ToString() on our XElement.
Console.WriteLine(inventory);
}
ÔÚÄÚ´æÖд´½¨XMLÎĵµ
static void CreateFunctionalXmlDoc()
{
XDocument inventoryDoc =
new XDocument(
new XDeclaration("1.0", "utf-8", "yes"),
&n
Ïà¹ØÎĵµ£º
À©Õ¹Struts2--×Ô¶¨ÒåStringºÍXML¸ñʽµÄResult
struts2ËäÈ»¼Ì³ÐÁËwebworkÓÅÐãµÄMVC·ÖÀ룬¿ÉÊÇÓÐºÜ¶àµØ·½ÈÃÈ˰Ù˼²»µÃÆä½â£¡×îÈÃÈËÀëÆ×µÄÊÇ£¬·µ»ØµÄ½á¹û¼¯ÖоÓȻûÓÐ
String£¬xmlÕâÁ½Öַdz£³£ÓõÄÀàÐÍ¡£»¹ÊÇ×Ô¼º¶¯ÊÖ£¬·áÒÂ×ãʳ£º
µÚÒ»ÖÖ·½Ê½£ºÊ¹ÓÓPlainText Result”
& ......
Ò»¡¢Libxml2½éÉÜ£º
Libxml2 ÊÇÒ»¸öxmlµÄcÓïÑÔ°æµÄ½âÎöÆ÷£¬±¾À´ÊÇΪGnomeÏîÄ¿¿ª·¢µÄ¹¤¾ß£¬ÊÇÒ»¸ö»ùÓÚMIT LicenseµÄÃâ·Ñ¿ªÔ´Èí¼þ¡£Ëü³ýÁËÖ§³ÖcÓïÑÔ°æÒÔÍ⣬»¹Ö§³Öc++¡¢PHP¡¢Pascal¡¢Ruby¡¢TclµÈÓïÑԵİ󶨣¬ÄÜÔÚWindows¡¢Linux¡¢Solaris¡¢MacOsXµÈƽ̨ÉÏÔËÐС£¹¦ÄÜ»¹ÊÇÏ൱ǿ´óµÄ£¬ÏàÐÅÂú×ãÒ»°ãÓû§ÐèÇóûÓÐÈκÎÎÊÌâ¡£
¶þ¡ ......
declare @x xml
set @x='
<ROOT>
<SM>
<SMID>88</SMID>
<SMCD>A5</SMCD>
<SMNM>ÁõÑó</SMNM>
<NDS>
<ND>
<SF>3</SF>
<NDID>88</NDID>
<NDCD>A5< ......
<!--
/* Font Definitions */
@font-face
{font-family:ËÎÌå;
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-alt:SimSun;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
@font-face
{font-family:PMingLiU;
panos ......
¡¡¡¡ÔÚ´ËÏȸÐлhttp://blog.chinaunix.net/u3/111961/showart_2187819.html
¡£ÕâÊÇÆª¼«ºÃµÄÎÄÕ¡£
¡¡¡¡ÔÚÉÏ´ÎѧϰÖУ¬ÎÒÃÇдÁËclientСÀý×Ó£¬·Ç³£¼òµ¥£¬¶øÇÒͨ¹ýdbus-binding-toolÉú³ÉµÄÍ·Îļþ£¬·Ç³£¹æ·¶¡£Ïà±ÈÖ´ÐУ¬serverÉÔ΢¸´ÔÓЩ£¬ÈÔȻʹÓÃÉϴεÄxmlÎļþ£¬µ«ÊÇÈ¥µôannotation£¬¸üΪ±¾ÔһЩ¡£Îļþwei.xmlÈçÏ£º
& ......