Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

¶ÁÈ¡ XMLÀà (XmlHelper)

using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
namespace System.Bwch.XmlConfig
{
/**////
/// ¶ÁÈ¡XMLÅäÖÃÎļþÀà
///
public class XmlHelper
{
private string strXmlPath = ""; //XmlÎĵµÂ·¾¶
private XmlDocument xmlDoc; //XMLÎĵµ
/**////
/// ³õʼ»¯ReadXmlÀà
///
/// XMLÎļþ·¾¶
public XmlHelper(string XMLPath)
{
if (!System.IO.File.Exists(XMLPath))
{
throw new Exception("ûÓÐÕÒµ½Ö¸¶¨µÄ·¾¶£º" + XMLPath + "µÄXMLÎĵµ");
}
strXmlPath = XMLPath;
xmlDoc = new XmlDocument();
xmlDoc.Load(XMLPath);
}
/**////
/// ¶ÁÈ¡XMLÎļþÖ¸¶¨¼üÖµµÄvalue Öµ
///
/// ¼üÖµµÄ·¾¶,¸ñʽΪ(¸ù½Úµã/½Úµã/×Ó½Úµã)
/// Ö¸¶¨¼üÖµµÄÊôÐÔÃû³Æ
/// valueÖµ
public string ReadXmlValue(string XMLNodePath,string valueName)
{
try
{
XmlElement xml = (XmlElement)xmlDoc.SelectSingleNode(XMLNodePath);
return xml.GetAttribute(valueName);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
/**////
/// дXMLÖ¸¶¨½ÚµãµÄÊôÐÔ
///
/// ¼üֵ·¾¶£¬¸ñʽΪ((¸ù½Úµã/½Úµã/×Ó½Úµã))
/// ÊôÐÔÃû³Æ
/// ÊôÐÔ
///
public bool WriteXmlValue(string XmlNodePath,string valueName, string Value)
{
try
{
XmlElement xml = (XmlElement)xmlDoc.SelectSingleNode(XmlNodePath);
xml.SetAttribute(valueName, Value); //ÉèÖÃ
xmlDoc.Save(strXmlPath); //±£´æ
return true;
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
/**//


Ïà¹ØÎĵµ£º

DOM4JÉú³ÉXMLÎĵµ


public int createXMLFile(String filename) {
  int returnValue = 0;
  Document document = DocumentHelper.createDocument();    //Éú³ÉDocument£¬ÓÃÓÚ¹ÜÀíXMLÎĵµ
  
  Element booksElement = document.addElement("books");    //Ìí¼Ó ......

java ×Ô¼º×öµÄ¶ÔXMLÎļþµÄ¶Áд²Ù×÷

XMLÎļþʵÀý£º
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Context>
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<Resource auth="Container" maxActive="20" name="sss" password="123"
type="javax.sql.DataSource" />
<Resource auth="Container" ......

asp.net+jquery+xmlʵÏÖ×î¼òµ¥µÄÁÄÌìÊÒ

×î½üÔÚsina¿´nbaµÄÎÄ×ÖÖ±²¥µÄʱºò£¬¶ÔÍøÕ¾ÓÒϽǵÄÄÇÒ»¸öÁÄÌì´°¿Ú²úÉúÐËȤ£¬¾Í¾ö¶¨×Ô¼ºÒ²×öÒ»¸ö¡£
    ÉÏÍø²é²é×ÊÁÏ£¬ÕâÑùµÄÁÄÌìÊÒÎ޷ǾÍÊÇÓû§ÊäÈëÊý¾Ý´«µ½·þÎñÆ÷±£´æ£¬È»ºóÓû§Ò³ÃæÔÙʵʱµØ´ÓÊý¾Ý¿âÈ¡³öÊý¾Ý£¬ÏÔʾÔÚÒ³ÃæÉÏ£¬¼´¿ÉÍê³ÉÒ»´ÎÁÄÌì²Ù×÷¡£
   Ê×ÏÈÎÒ¶¨ÒåÁËÒ»¸öxmlÎļþ£¬ÓÃÓÚ±£´æÓû§ ......

XML ¸ñʽ

ÏÖÔÚÎÒÃÇÔÝÇÒʹÓÓ¼Çʱ¾”À´´´½¨ÎÒÃǵÄXMLÎļþ°É¡£ÏÈ¿´Ò»¸öXMLÎļþ£º 
¡¡¡¡Àý1 
¡¡¡¡¡´?xml version="1.0" encoding="gb2312" ?¡µ 
¡¡¡¡¡´²Î¿¼×ÊÁÏ¡µ 
¡¡¡¡ ¡´Êé¼®¡µ 
¡¡¡¡ ¡´Ãû³Æ¡µXMLÈëÞ«½â¡´/Ãû³Æ¡µ 
¡¡¡¡ ¡´×÷Õß¡µÕÅÈý¡´/×÷Õß¡ ......

XMLÌØÊâ·û號

ÔÚweb.config×ö參數設¶¨時Óöµ½ÌØÊâ×ÖÔª value="http://www.yahoo.com.tw/default.aspx?sid=111111111&uid=test"
&uid這µØ·½會³ö錯...換³É&amp;uid ¾ÍOKÁË~~
幾個
對ÕÕÈçÏÂ:
< Сì¶
&lt;
> ´óì¶
&gt;
&
&amp ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ