XMLÎļþÐ޸IJÙ×÷
´ËXMLʵÀýÒÔ·þÎñÆ÷¶Ë²¿ÃŹÜÀíΪÀý£º£¨Æä½çÃæÈçÏ£©
private void btn_UpdateGroup_Click(object sender, EventArgs e)
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load("...\\...\\group.xml");
XmlNodeList list = xmlDoc.SelectSingleNode("grouplist").ChildNodes;//»ñµÃ¸ù½ÚµãgrouplistϵÄËùÓÐ×Ó½Úµã //±éÀúËùÓÐ×Ó½Úµã
foreach (XmlNode node in list)
{
XmlElement xe = (XmlElement)node;//½«×Ó½ÚµãÀàÐÍת»»ÎªXmlElementÀàÐÍ
string departmentName = this.listBox_Group.SelectedItem.ToString();
string[] array1 = new string[2];
array1 = departmentName.Split(' ');
if (xe.GetAttribute("id") == array1 [1])//¸ù¾Ý²¿ÃźŵÄIDÖµ£¬ÕÒµ½ÆäÔÚXMLÖеĽáµã£¬½«ÆäÐ޸ijÉtextBoxÖеÄÖµ
{
xe.InnerText = tbx_NewGroupName.Text;//½«XMLÖеIJ¿ÃÅÃûÐ޸ijÇtextboxÖеÄÐÂÃû³Æ¡£
}
Ïà¹ØÎĵµ£º
Ç°¶Îʱ¼ä¸ø¿Í»§×öÁ˼¸¸öÍøÒ³£¬¿Í»§ÒªÇóÔÚ×Ô¼ºµÄÍøÕ¾ÖÐÏÔʾ×Ô¼ºÔÚÐÂÀ˲©¿ÍÀïµÄÎÄÕ£¬×÷ΪÍøÕ¾µÄÒ»²¿·Ö¡£ÕâÑùµÄÇé¿ö¿ÉÒÔ½â¾ö£¬Ö÷Òª¿ÉÒÔͨ¹ý²©¿ÍÖÐµÄ XMLÀ´ÊµÏÖ£¬Í¨¹ýÓÃaspÀ´¶ÁÈ¡²©¿ÍÖÐXML£¬½«²©¿ÍÖеıêÌâ¡¢·¢²¼Ê±¼äµÈÐÅÏ¢ÏÔʾÔÚÍøÕ¾ÖС£µ«ÊÇÔÚʹÓõĹý³ÌÖУ¬³öÏÖÁËÒ»¸öÎÊÌ⣺µ±²©¿ÍÖÐÌí¼ÓÎÄÕºó£¬ÔÚÍøÒ³ÖжÁÈ¡²©¿ÍÖеÄXMLºó½ ......
DOM³õ²½
DOMÊÇDocument Object ModelµÄËõд£¬¼´Îĵµ¶ÔÏóÄ£ÐÍ¡£Ç°Ãæ˵¹ý£¬XML½«Êý¾Ý×é֯Ϊһ¿ÅÊ÷£¬ËùÒÔDOM¾ÍÊǶÔÕâ¿ÅÊ÷µÄÒ»¸ö¶ÔÏóÃèÐð¡£Í¨Ë×µÄ˵£¬¾ÍÊÇͨ¹ý½âÎöXMLÎĵµ£¬ÎªXMLÎĵµÔÚÂß¼ÉϽ¨Á¢Ò»¸öÊ÷Ä£ÐÍ£¬Ê÷µÄ½ÚµãÊÇÒ»¸ö¸ö¶ÔÏó¡£ÎÒÃÇͨ¹ý´æÈ¡ÕâЩ¶ÔÏó¾ÍÄܹ»´æÈ¡XMLÎĵµµÄÄÚÈÝ¡£
ÏÂÃæÎÒÃÇÀ´¿´Ò»¸ö¼òµ¥µÄÀý×Ó£¬¿´¿´ÔÚDOMÖ ......
Õâ¸öÊDzÎÕÕibmÍøÕ¾ÉϵÄÎÄÕÂ×öµÄ¡£
xmlÔ´Îļþ£º
<?xml version="1.0"?>
<!DOCTYPE rss PUBLIC
"-//Netscape Communications//DTD RSS 0.91//EN"
"http://my.netscape.com/publish/formats/rss-0.91.dtd"
>
<rss version="0.91">
<channel>
<title>Meerkat: An Open2 Wire Servic ......
ʹÓÃXMLList¶ÁÈ¡XMLÊý¾Ý
¡¡¡¡XML¶ÔÏóÌṩÁËÒ»¸ö·µ»ØXMLListÀàÐ͵ķ½·¨elements()£¬¼È·µ»ØËùÓÐXML¶ÔÏóµÄ×ÓÔªËؽڵ㣬ËæºóÎÒÃÇ¿ÉÒÔͨ¹ýfor eachÓï¾äÑ»·Ôò¿É·ÃÎʵ½Õû¸öXMLÊý¾ÝÄÚÈÝ¡£ÒÔÉÏÃæ´´½¨ÄÚ²¿XMLÎĵµµÄXMLÊý¾ÝΪÀý£¬Ïêϸ¼ûÈçÏ´úÂë¿é£º
varlist:XMLList=pXml.elements();
foreach(varelement:XMLinlist)
{
¡¡¡¡// ......
½üÀ´×Ô¼ºÔÚ×öxmlµÄ½âÎöÆ÷¡£ÀûÓõ½ÁËcmarkupÀ࣬¾Íµ±×ö´æ´¢°É£¡ÓÐÐèÒªµÄÅóÓÑ¿ÉÒÔÃ鼸ÑÛ¡£
HTREEITEM itemTemp1,itemTemp2;
CString str1,str2;
char strtemp[100];
static bool result = true;
strtemp[0] = 0;
if (result)
{
xml.FindElem();
}
&nbs ......