LINQ to XMLº¯Êý¹¹Ôì·½·¨
±êÇ©£ºÊý¾Ý·ÃÎÊ LINQ to XML
LINQ to XML²¢²»´òËãÌæ´ú±ê×¼µÄXML API£¬Ö»ÊDz¹³äÁËÕâЩ±ê×¼XMLÀà LINQ to XMLº¯Êý¹¹Ôì·½·¨ º¯Êý¹¹½¨·½Ê½(functional construction):
ÔÚÕâÖÖ·½Ê½ÖУ¬¹¹Ô캯ÊýµÄµ÷ÓÿÉÒÔÓ÷´Ó³XMLÎĵµ½á¹¹µÄ·½Ê½Ç¶Ìס£
Àý£º
.....
XDocument xdoc = new XDocument( //XCocument ±íʾÍêÕûµÄXMLÎĵµ new XELement("customers", new XElement("customer", new XAtrribute("ID","A"), new XAtrribute("City","New York"), new XAtrribute("Region","North
Ïà¹ØÎĵµ£º
ºÍAndroid UI layoutÒ»Ñù£¬ÎÒÃÇÒ²¿ÉÒÔÔÚXMLÖж¨ÒåÓ¦ÓóÌÐòµÄ²Ëµ¥¡£Í¨¹ýÔڲ˵¥µÄonCreateOptionsMenu·½·¨ÖÐÅòÕͲ˵¥layout¡£ÕâÑù×ö»áʹÎÒÃǵijÌÐò´úÂë¼òµ¥¶àÁË£¬¶øÇÒ¾¡¿ÉÄܵĽ«¸ü¶àµÄ½çÃæÉè¼Æ²¿·Ö·Åµ½XML£¬±ãÓÚä¯ÀÀ¡£
1. ÔÚ¹¤³ÌµÄ/res/Îļþ¼ÐÏ´´½¨menuÎļþ¼Ð£¬ÓÃÀ´±£´æÄãΪӦÓóÌÐò¶¨ÒåµÄ²Ëµ¥XMLÎļþ¡£
Ôڲ˵¥XML ......
/// <summary>
/// DataTable-------------------->XML --String
/// </summary>
public static String ToXmlString(DataTable dt)
{
StringWriter tr = new StringWriter();
try
{
dt.WriteXml(tr); ......
×î³£¼ûµÄXMLÊý¾ÝÀàÐÍÓУºElement, Attribute£¬Comment, Text.
Element, Ö¸ÐÎÈç<Name>Tom<Name>µÄ½Úµã¡£Ëü¿ÉÒÔ°üÀ¨£ºElement, Text, Comment, ProcessingInstruction, CDATA, and EntityReference.
Attribute, Ö¸ÔÚ<Employee >ÖеĴ ......