using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Text;
using System.Xml;
using System.Xml.XPath;
using System.Xml.Xsl;
namespace PanRoor
{
    /// <summary>
    /// XML 的摘要说明
    /// </summary>
    public class XMLX : Page
    {
        public XMLX()
        {
            
            //
            // TODO: 在此处添加构造函数逻辑
            //
        }
        
        public string CreateXML(string NoAndOff, string DrawedImagePath, string LucencyPercent,string PicVal,string RightSpace, string BottoamSpace)
        {
            //建一个新的空的XML文档
            XmlTextWriter objXml = new XmlTextWriter(Server.MapPath("~/App_Data/WM_Xml.xml"), null);
            //格式化输出XML文档
            objXml.Formatting = Formatting.Indented;
            objXml.Indentation = 4;
            //写入XML文档标记
            objXml.WriteStartDocument();
            //写入XML文档注释
            objXml.WriteComment("Created XML" + Context.Timestamp);
            //写入根元素
            objXml.WriteStartElement("WKConfig");
            //写入元素
            objXml.WriteStartElement("Config");
            //写入属性
            objXml.WriteAttributeString("Technology", "ASP.NET 2.0");
            //写入属性值
            objXml.WriteAttributeString("Author", "李斌");
            //写入子元素及文本值
            objXml.WriteElementString("Title", "水印参数配置");
            //写入子元素及文本值
            objXml.WriteElementString("Version", "ImageWaterMark V2.0");
            //写入元素
            objXml.WriteStartElement("Parameter");
            //写入子元素及文本值
            objXml.WriteElementString("NoAndOff", NoAndOff);
            objXml.WriteElementString("DrawedImagePath", DrawedImagePath);
            objXml.WriteElementString("LucencyPercent", LucencyPercent);
            objXml.WriteElementString("PicVal", PicVal);
            objXml.WriteElementString("RightSpace", RightSpace);
            objXml.WriteElementString("BottoamSpace", BottoamSpace);

            //关闭子元素、元素、根元素
            objXml.WriteEndElement();
            objXml.WriteEndElement();
            objXml.WriteEndElement();
            //清除缓存
            objXml.Flush();
            //关闭对象
            objXml.Close();
            return "";
        }
        public string XMLRead(string Value)
        {

            XmlDocument xd = new XmlDocument();
            xd.Load(Server.MapPath("~/App_Data/WM_Xml.xml"));

            XmlNodeList xnl = xd.GetElementsByTagName(Value);
            if (xnl.Count == 0)
                return "";
            else
            {
                XmlNode mNode = xnl[0];
                return mNode.InnerText;
            }
        }
    

    }
}