xml ¶Áд
¶Á£º
//´ò¿ªÄ³Îļþ(¼ÙÉèweb.configÔÚ¸ùĿ¼ÖÐ)
string filename=Server.MapPath("/") + @"WebApplication1\web.config";
XmlDocument xmldoc= new XmlDocument();
xmldoc.Load(filename);
//µÃµ½¶¥²ã½ÚµãÁбí
XmlNodeList topM=xmldoc.DocumentElement.ChildNodes;
foreach(XmlElement element in topM)
{
if(element.Name.ToLower()=="appsettings")
{
//µÃµ½¸Ã½ÚµãµÄ×Ó½Úµã
XmlNodeList nodelist=element.ChildNodes;
if ( nodelist.Count >0 )
{
//DropDownList1.Items.Clear();
foreach(XmlElement el in nodelist)//¶ÁÔªËØÖµ
{
//DropDownList1.Items.Add(el.Attributes["key"].InnerXml);
//this.TextBox2.Text=el.Attributes["key"].InnerText;
this.TextBox2.Text=el.Attributes["key"].Value;
this.Label1.Text=el.Attributes["value"].Value;
//ͬÑùÔÚÕâÀï¿ÉÒÔÐÞ¸ÄÔªËØÖµ,ÔÚºóÃæsave¡£
// el.Attributes["value"].Value=this.TextBox2.Text;
}
}
}
}
xmldoc.Save(filename);
ÔÚij½ÚµãÏÂÔö¼ÓÒ»¸öÔªËØ£¬²¢ÉèÖÃÖµ£º
if(element.Name.ToLower()=="appsettings")
{
XmlElement elem =xmldoc.CreateElement("add");
element.AppendChild(elem);
elem.InnerText="ltp";
xmldoc.Save(filename);
}
Ч¹û£º
<appSettings>
<add key="ÃÜÂë" value="admin" />
<add>ltp</add>
</appSettings>
ÔÚij½ÚµãÏÂÔö¼ÓÒ»¸öÔªËØ£¬²¢Ôö¼ÓÁ½¸öÊôÐÔ£º
if(element.Name.ToLower()=="appsettings")
{
XmlElement elem =xmldoc.CreateElement("add");
element.AppendChild(elem);
XmlAttribute xa=xmldoc.CreateAttribute("key");
xa.Value="ltp";
XmlAttribute xa2=xmldoc.CreateAttribute("value");
xa2.Value="first";
elem.SetAttributeNode(xa);
elem.SetAttributeNode(xa2);
xmldoc.Save(filename);
}
Ч¹û£º
<appSettings>
<add key="ÃÜÂë" value="admin" />
<add key="ltp" value="first" />
</appSettings>
//Ìí¼Ó¿ÕÔªËØ£º
XmlNode node=doc.CreateElement(groupname);
node.InnerText="";
doc.LastChild.AppendChild(node);
doc.Save(xmlfile);
ɾ³ýÒ»¸ö½ÚµãÔªËØ
string itemname=this.listBox1.SelectedItem.ToString();
this.listBox1.Items.Remove(this.listBox1.SelectedItem);
//begin del xmlfile
XmlDocument doc=new
Ïà¹ØÎĵµ£º
/* Author: ÑîÓî yangyu@sina.cn */
/*
Ó÷¨Ê¾Àý£º
$cls_xml = new cls_xml();
if ($array){
$cls_xml->array2xml($array);
echo $cls_xml->getXml();
}else{
echo '';
}
*/
class cls_xml{
var $xml;
&nbs ......
Ä¿Ç°ÔÚʹÓÃDOMºÍdom4j¶ÔXMLÎļþ½øÐÐÔöɾ¸Ä²é£¬Èç¹ûÎÒÔÚͬһ¸öÏß³ÌÖÐ×ö¶à´ÎÔöɾ¸Ä²Ù×÷£¬ÈçºÎ±£Ö¤DOMÄÚ´æͬ²½ºÍÎïÀíÎļþͬ²½£¿ÓÖÈçºÎÇåÀíÔÚÄÚ´æÖÐÒѼÓÔصÄÊý¾Ý£¿
ÎÊÌâ²¹³ä£º
Äã˵µÄÕâÖÖ¾ÍÊǺܵ¥´¿µÄÔÚÒ»¸öÏß³ÌÖÐÖ´ÐÐËùÓеIJÙ×÷£¬Èç¹ûÎÒÊÇÔÚµ¥Ïß³ÌÖвÙ×÷£¬Ã¿×öÒ»´ÎÔöɾ¸Ä²éµÄÒ»ÖÖ£¬ÎÒ¶¼Òª±£´æµ½ÎļþÖÐÈ¥£¬È磺
µÚÒ»´Î£ºÔö¼ ......
JAVA¶ÁXML£ºsax,dom,jdom,dom4jµÄ±È½ÏÒÔ¼°Ñ¡Ôñ(ת)
ÔÎÄ£ºwww.hicourt.gov.cn/homepage/show9_content.asp
SAX£º ......
ÔÎÄÁ´½Ó£ºhttp://www.cnblogs.com/ding0910/archive/2007/07/12/815407.html
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Web;
using System.Web.Services;
using BX.Interface;
......
XPath Óï·¨
2007-06-05 17:24
XPath Óï·¨
×÷Õß:w3pop.com ·Òë/ÕûÀí:w3pop.com ·¢²¼:2007-04-29 ä¯ÀÀ:674 :: ::
XPath Nodes(½Úµã) XPath Axes
XPath uses path expressions to select nodes or node-sets in an XML document. The node is selected by following a path or steps.
XPath ͨ¹ý·¾¶±í´ïʽ´ÓXM ......