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 ......
package book.xml;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Stack;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.Default ......
¼òµ¥µØ˵£¬xslÊÇ˵Ã÷xmlÈçºÎ±í´ï³öÀ´µÄÑùʽÎļþ£¬¶øxsd¸ø³öxmlÎļþµÄ¸ñʽÃèÊö
Èç¹û˵xmlÊÇÒ»µþ³®Æ±£¬xsd¾ÍÊÇÑé³®»ú£¬¿´¿´ÀïÃæÓÐûÓмٳ®£¬¶øxslÊǵ㳮»ú£¬¿´¿´µ½µ×ÊǶàÉÙÇ®¡£ÓÃxml¿ÉÒÔ²»ÓÃxsd£¬¾ÍÏñ»¨Ç®µÄʱºò²»Ò»¶¨ÒªÑé³®Ò»Ñù£¬µ«ÊÇÊÕÇ®µÄÈËÒ»°ãÊÇÏëÒªÑéµÄ¡£¶ø»¨Ç®µÄʱºò²»Äܲ»µã³®£¬²»µãÄǾͲ»ÊÇ»¨Ç®ÁË£¬ÊÇÍæÇ®¡£µ±È»ÁË£ ......
µ±ÊäÈë ¡·Ê±×Ô¶¯²¹È« µ±ÊäÈ롶/ʱ×Ô¶¯²¹È«
“£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½
" File: closetag.vim
" Summary: Functions and mappings to close open HTML/XML tags
" Uses: <C-_> -- close matching open tag
" Author: Steven Mueller <di ......