xmlÎļþ²Ù×÷С½á ¹ØÓÚ·½·¨SelectSingleNodeµÄÓ÷¨
×î³£¼ûµÄXMLÊý¾ÝÀàÐÍÓУºElement, Attribute£¬Comment, Text.
Element, Ö¸ÐÎÈç<Name>Tom<Name>µÄ½Úµã¡£Ëü¿ÉÒÔ°üÀ¨£ºElement, Text, Comment, ProcessingInstruction, CDATA, and EntityReference.
Attribute, Ö¸ÔÚ<Employee id=”12345”>ÖеĴÖÌ岿·Ö¡£
Comment£¬Ö¸ÐÎÈ磺<!-- my comment --> µÄ½Úµã¡£
Text£¬Ö¸ÔÚ<Name>Tom<Name>µÄ´ÖÌ岿·Ö¡£
ÔÚXMLÖУ¬¿ÉÒÔÓÃXmlNode¶ÔÏóÀ´²ÎÕÕ¸÷ÖÖXMLÊý¾ÝÀàÐÍ¡£
2.1 ²éѯÒÑÖª¾ø¶Ô·¾¶µÄ½Úµã£¨¼¯£©
objNodeList = objDoc.SelectNodes(“Company/Department/Employees/Employee”)
»òÕß
objNodeList = objNode.SelectNodes(“/Company/Department/Employees/Employee”)
ÒÔÉÏÁ½ÖÖ·½·¨¿É·µ»ØÒ»¸öNodeList¶ÔÏó£¬Èç¹ûÒª·µ»Øµ¥¸ö½Úµã¿ÉʹÓÃSelectSingleNode·½·¨£¬¸Ã·½·¨Èç¹û²éѯµ½Ò»¸ö»ò¶à¸ö½Úµã£¬·µ»ØµÚÒ»¸ö½Úµã£»Èç¹ûûÓвéѯµÄÈκνڵ㷵»Ø Nothing¡£ÀýÈ磺
objNode = objNode.SelectSingleNode(“/Company/Department/Employees/Employee”)
If Not (objNode is Nothing) then
‘- Do process
End If
2.2 ²éѯÒÑÖªÏà¶Ô·¾¶µÄ½Úµã£¨¼¯£©
¿ÉʹÓÃÀàËÆÓÚÎļþ·¾¶µÄÏà¶Ô·¾¶µÄ·½Ê½À´²éѯXMLµÄÊý¾Ý
objNode = objDoc.SelectSingleNode(“Company/Department”)
objNodeList = objNode.SelectNodes(“../Department)
objNode = objNode.SelectNode(“Employees/Employee”)
2.3 ²éѯÒÑÖªÔªËØÃûµÄ½Úµã£¨¼¯£©
ÔÚʹÓò»¹æÔòµÄ²ã´ÎÎĵµÊ±£¬ÓÉÓÚ²»ÖªµÀÖмä²ã´ÎµÄÔªËØÃû£¬¿ÉʹÓÃ//·ûºÅÀ´Ô½¹ýÖмäµÄ½Úµã£¬²éѯÆä×Ó£¬Ëï»ò¶à²ã´ÎϵÄÆäËûËùÓÐÔªËØ¡£ÀýÈ磺
objNodeList = objDoc.SelectNodes(“Company//Employee”)
2.4 ²éѯÊôÐÔ£¨attribute£©½Úµã
ÒÔÉϵĸ÷ÖÖ·½·¨¶¼·µ»ØÔªËØ£¨element)½Úµã£¨¼¯£©£¬·µ»ØÊôÐÔ£¨attribute£©£¬Ö»ÐèÒª²ÉÓÃÏàÓ¦µÄ·½·¨£¬ÔÚÊôÐÔÃûÇ°¼ÓÒ»¸ö@·ûºÅ¼´¿É£¬ÀýÈ磺
objNodeList = objDoc.SelectNodes(“Company/Department/Employees/Em
Ïà¹ØÎĵµ£º
Java codeFormat ft=Format.getRawFormat();
ft.setEncoding("utf-8");
ft.setIndent(" ");//ÉèÖÃËõ½ø
XMLOutputter outputter=new XMLOutputter(ft);//ÉèÖÃXML¸ñʽ
Õâλ˵µÄ²»´í£»
ÔÚieÀïÃ棬ËüÄÜ°Ñxml×Ô¶¯½âÎö³ÆÊ÷Ðνṹ£¬ËùÒÔ¿´ÆðÀ´Ã»ÎÊÌ⣬ÔÚ¼Çʱ¾ÀïÃ棬¾Í²»ÐÐÁ ......
IsolatedStorageFile£º°üº¬ÎļþºÍÊý¾ÝµÄ¶ÀÁ¢´æ´¢Çø
datasetÊý¾Ý´æ´¢µ½±¾µØxmlÎĵµ£¬´úÂë´¦ÀíÈçÏÂ
public static void WriteDataToXML(DataSet dataset, string dataname)
{
try
{
IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForAssembly(); / ......
/// <summary>
/// DataTable-------------------->XML --String
/// </summary>
public static String ToXmlString(DataTable dt)
{
StringWriter tr = new StringWriter();
try
{
dt.WriteXml(tr); ......
AJAX (Òì²½ JavaScript ºÍ XML) ÊǸöвúÉúµÄÊõÓï,רΪÃèÊöJavaScriptµÄÁ½ÏîÇ¿´óÐÔÄÜ.ÕâÁ½ÏîÐÔ
ÄÜÔÚ¶àÄêÀ´Ò»Ö±±»ÍøÂ翪·¢ÕßËùºöÂÔ,Ö±µ½×î½üGmail, Google suggestºÍgoogle MapsµÄºá¿Õ³öÊÀ²ÅʹÈË
ÃÇ¿ªÊ¼Òâʶµ½ÆäÖØÒªÐÔ.
ÕâÁ½Ïî±»ºöÊÓµÄÐÔÄÜÊÇ:
* ÎÞÐèÖØÐÂ×°ÔØÕû¸öÒ³Ãæ±ãÄÜÏò·þÎñÆ÷·¢ËÍÇëÇó.
* ¶ÔXMLÎĵµµÄ½âÎöºÍ´¦Àí£®
......
1,dz´®Ðл¯£ºÖ»´®Ðл¯ÀàµÄ¹«¹²×ֶκÍÊôÐÔ
¹«¹²ÊôÐÔ±ØÐëÊǿɶÁÇÒ¿ÉдµÄ
ʹÓÃÃüÃû¿Õ¼ä£ºusing System.Xml.Serialization;
ÒÔBookÀàΪÀý£º
´®Ðл¯Ä£°å£º
public ......