一,anychart入门

  1. 首先引入anychart的js,
  2. 在js中实例化chart对象,chart1和chart2,以及chart1和chart2对象在页面运行时将要附加到的页面节点<Div1>和<Div2>

 

<head id="Head1" runat="server">
    <title>风险感知</title>
    <link href="../../../Css/water.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="../../../JS/jquery-1.6.4.min.js"></script>
    <script type="text/javascript" src="../../../AnyChart/AnyChart.js"></script>
    <script type="text/javascript">
        var chart1 = new AnyChart("../../../AnyChart/AnyChart.swf");
        chart1.width = "100%";
        chart1.height = "250px";
        chart1.wMode = 'transparent'; 

        var chart2 = new AnyChart("../../../AnyChart/AnyChart.swf");
        chart2.width = "100%";
        chart2.height = "250px";
        chart2.wMode = 'transparent';
    </script>
    <script type="text/javascript">
        function showFORM(ID) {
            var answer = window.showModalDialog("ZDZD.aspx?ID="+ID,"", "dialogWidth=650px;dialogHeight=300px");
            if (answer) {
                window.location.reload();    //   刷新父窗口
                //winow.location.reload(true);
            }
        }
    </script>
    <style type="text/css">
       .hidden{display:none}
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
      <table style="WIDTH: 100%" cellspacing="0" cellpadding="0" border="0">
        <tr>
         <td class="Biaoti">风险感知</td>
        </tr>
     </table>
      <table style="WIDTH: 100%"  cellpadding="0"cellspacing="0" border="0">
      <tr>
            <td  nowrap="nowrap" style="width:30%">
             <asp:UpdatePanel ID="updatePanel1" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="true">
                    <ContentTemplate>
                &nbsp;&nbsp; 作业区:
            <asp:DropDownList ID="DDLzyq" runat="server" AutoPostBack="True" 
                DataTextField="ZYQ" DataValueField="ZYQDM" 
                onselectedindexchanged="DDLzyq_SelectedIndexChanged" CssClass="BigInput" Width="100px" Height="20px">
            </asp:DropDownList>&nbsp;&nbsp;
            集气站:
            <asp:DropDownList ID="DDLjqz" runat="server" DataTextField="JQZ" 
                DataValueField="JQZDM" CssClass="BigInput" Width="100px" Height="20px">
            </asp:DropDownList>
        &nbsp;&nbsp;
             </ContentTemplate>
               </asp:UpdatePanel>
                </td>
                <td>
                &nbsp;<asp:Button ID="btnSearch" runat="server" onclick="BtnSearch_Click" Text="查找" CssClass="BigButton" />
            </td>
      </tr>
       </table>
      <div>
    
    <div id="Div1"></div>
    <div id="Div2"></div>

   <table style="WIDTH: 100%"  cellpadding="0"cellspacing="0" border="0">
    <tr>
      <td>
    <asp:GridView ID="GridView1" runat="server"  PageSize="22" 
                            AutoGenerateColumns="False" Width="100%"
                            BorderColor="#A9DCD8"  EmptyDataText="没有查询到符合条件的数据" >  
     <FooterStyle ForeColor="#333333" BackColor="White"></FooterStyle>
          <AlternatingRowStyle CssClass="table_content_main"></AlternatingRowStyle>
          <RowStyle  CssClass="grid_rows_odd"> </RowStyle>
          <HeaderStyle Font-Bold="True" HorizontalAlign="Center" CssClass="Biaoti1"></HeaderStyle>
      <Columns>
      <asp:TemplateField HeaderText="井号">
        <ItemTemplate>
            <asp:LinkButton ID="lbn" runat="server" CommandArgument='<%#DataBinder.Eval(Container.DataItem,"SCJDM")%>' OnClick="lbn_Click"><%# DataBinder.Eval(Container.DataItem,"JH")%></asp:LinkButton>
        </ItemTemplate>
      </asp:TemplateField>
          <asp:BoundField DataField="SCCW" HeaderText="生产层位"/>
          <asp:BoundField DataField="WZLL" HeaderText="无阻流量(万方)" />
          <asp:BoundField DataField="MQCL" HeaderText="目前产量(万方)" />
          <asp:BoundField DataField="PJJG" HeaderText="评价结果" />
           <asp:BoundField DataField="SCJDM" HeaderText="生产井代码" >
          <FooterStyle CssClass="hidden" />
          <HeaderStyle CssClass="hidden" />
          <ItemStyle CssClass="hidden" />
          </asp:BoundField>
          <asp:BoundField DataField="ID" HeaderText="主键标示符" >
          <FooterStyle CssClass="hidden" />
          <HeaderStyle CssClass="hidden" />
          <ItemStyle CssClass="hidden" />
          </asp:BoundField>
          <asp:TemplateField HeaderText="处理措施">
              <ItemTemplate>
                <a href="javascript:showFORM('<%#Eval("ID")%>')">制度制定</a>
              </ItemTemplate>         
          </asp:TemplateField>   
     </Columns>
    </asp:GridView>  

    
    <webdiyer:aspnetpager ID="AspNetPager1" runat="server" AlwaysShow="True" 
        PageSize="20" ShowCustomInfoSection="Left"  CustomInfoSectionWidth="20%"
        CustomInfoHTML="<font class='small'>总记录%RecordCount%条 第%CurrentPageIndex%/%PageCount%页 每页%PageSize%条</font>"
        FirstPageText="首页" PrevPageText="上页" NextPageText="下页" LastPageText="尾页" 
        ShowPageIndex="False" ShowMoreButtons="False" 
        OnPageChanging="AspNetPager1_PageChanging">  
    </webdiyer:aspnetpager>  
        <div style='text-align:center'> 
           <asp:HyperLink ID="HyperLink1" runat="server" 
                NavigateUrl="~/Forms/QJGL/CSJ/ZDGLlist.aspx">制度管理</asp:HyperLink>
        </div>   
        </td>
    </tr>
  </table>
    </form>
</body>
</html>

 

3.在后台的Page_Load中添加获得曲线的方法

#region 根据生产井代码获得油套压曲线和产气量曲线
    /// <summary>
    /// 根据生产井代码获得油套压曲线和产气量曲线
    /// </summary>
    /// <param name="scjdm"></param>
    public void GetChartData(string scjdm)
    {
        DataTable dt = GetData(scjdm);
        string strXml = string.Empty;
        string strXml2 = string.Empty;
        string xmlFile = "../../../ChartXml/QJGL/YTY.XML";
        string xmlFile2 = "../../../ChartXml/QJGL/CQL.XML";

        strXml = GetXmlDataForYTY(xmlFile, dt);
        strXml2 = GetXmlDataForRCQ(xmlFile2, dt);


        ClientScriptManager cs = Page.ClientScript;

        string chart1 = @" var chartData1 = '" + strXml + "';";
        chart1 += "chart1.setData(chartData1);";
        chart1 += "chart1.write(\"Div1\");";

        string chart2 = @" var chartData1 = '" + strXml2 + "';";
        chart2 += "chart2.setData('" + strXml2 + "');";
        chart2 += "chart2.write(\"Div2\");";
        if (!cs.IsStartupScriptRegistered(this.GetType(), "Div1"))
        {
            cs.RegisterStartupScript(this.GetType(), "Div1", chart1 + chart2, true);
        }
    }
    #endregion

    #region 取得油套压曲线的xml字符串
    /// <summary>
    /// 取得油套压曲线的xml字符串
    /// </summary>
    /// <param name="xmlData"></param>
    /// <param name="_dtScore"></param>
    /// <returns></returns>
    private string GetXmlDataForYTY(string xmlData, DataTable _dt)
    {
        try
        {
            string str = string.Empty;
            XmlDocHelper xmlDocHelper = new XmlDocHelper(xmlData, XmlPathType.VirtualPath);

            //设置要显示的数据
            if (null != _dt)
            {
                if (_dt.Rows.Count > 0)
                {
                    try
                    {
                        xmlDocHelper.AddChildNodeForYTY(@"anychart/charts/chart/data", _dt);
                    }
                    catch (Exception E)
                    {
                        MessageBox.Show("生成油套压曲线异常");
                    }

                }
            }
            //返回最后构造好的xml文件,在前台js中显示
            str = xmlDocHelper.XmlDocument.DocumentElement.OuterXml;

            return str;
        }
        catch (Exception ex)
        {
            MessageBox.Show("生成油套压曲线异常");
        }
        return null;
    }
    #endregion

    #region 取得产气量曲线的xml字符串
    /// <summary>
    /// 取得产气量曲线的xml字符串
    /// </summary>
    /// <param name="xmlData"></param>
    /// <param name="_dtScore"></param>
    /// <returns></returns>
    private string GetXmlDataForRCQ(string xmlData, DataTable _dt)
    {
        try
        {
            string str = string.Empty;
            XmlDocHelper xmlDocHelper = new XmlDocHelper(xmlData, XmlPathType.VirtualPath);

            //设置要显示的数据
            if (null != _dt)
            {
                if (_dt.Rows.Count > 0)
                {
                    try
                    {
                        xmlDocHelper.AddChildNodeForRCQ(@"anychart/charts/chart/data", _dt);
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show("生成油套压曲线异常");
                    }
                }


            }
            //返回最后构造好的xml文件,在前台js中显示
            str = xmlDocHelper.XmlDocument.DocumentElement.OuterXml;

            return str;
        }
        catch (Exception ex)
        {
            MessageBox.Show("生成日产气曲线异常");
        }
        return null;
    }
    #endregion

YTY.XML

<anychart>
    <settings>
        <animation enabled="false"/>
    </settings>
  <charts>
    <chart plot_type="CategorizedVertical">
        <chart_settings>
        <chart_background enabled="false">
          <inside_margin left="0" top="0" right="0" bottom="0"/>
        </chart_background>
            <title position="Right">
                <text>油套压曲线</text>
                <background enabled="false"/>
            </title>
            <axes>
                <x_axis>
            <title>
              <text></text>
            </title>
                </x_axis>
          <y_axis>
            <title>
              <text>单位:Mpa</text>
            </title>
          </y_axis>
            </axes>
        </chart_settings>
        <data_plot_settings default_series_type="Spline">
            <line_series>
                <tooltip_settings enabled="true">
                    <format>{%SeriesName}:{%YValue} ({%Name})</format>
                </tooltip_settings>
                <line_style>
                    <line thickness="3"/>
                </line_style>
            </line_series>
        </data_plot_settings>
        <data>
        </data>
    </chart>
  </charts>
</anychart>
            
            

CQL.XML

<anychart>
    <settings>
        <animation enabled="True"/>
    </settings>
  <charts>
    <chart plot_type="CategorizedVertical">
        <chart_settings>
        <chart_background enabled="false">
          <inside_margin left="0" top="0" right="0" bottom="0"/>
        </chart_background>
            <title position="Right">
                <text>日产气曲线</text>
                <background enabled="false"/>
            </title>
            <axes>
                <x_axis>
            <title>
              <text></text>
            </title>
                </x_axis>
          <y_axis>
            <title>
              <text>单位:万方</text>
            </title>
          </y_axis>
            </axes>
        </chart_settings>
        <data_plot_settings default_series_type="Spline">
            <line_series>
                <tooltip_settings enabled="true">
                    <format>{%SeriesName}:{%YValue}({%Name})</format>
                </tooltip_settings>
                <line_style>
                    <line thickness="3"/>
                </line_style>
            </line_series>
        </data_plot_settings>
        <data>
        </data>
    </chart>
  </charts>
</anychart>
            
            

 XmlDocHelper

using System;
using System.Web;
using System.Xml;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;


    /// <summary>
    /// xml文件所在路径类型
    /// </summary>
    public enum XmlPathType
    {
        AbsolutePath,  //绝对路径
        VirtualPath    //虚拟路径
    }

    public class XmlDocHelper
    {
        private XmlDocument xmlDoc = new XmlDocument();
        private string m_XmlFilePath;
        private XmlPathType m_XmlFilePathType;

        public XmlDocument XmlDocument
        {
            get { return xmlDoc; }
        }

        public string XmlFilePath
        {
            get { return m_XmlFilePath; }
            set { m_XmlFilePath = value; }
        }

        #region 构造函数
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="xmlFilePath">文件路径</param>
        public XmlDocHelper(string xmlFilePath)
        {
            this.m_XmlFilePath = xmlFilePath;
            this.m_XmlFilePathType = XmlPathType.VirtualPath;
            GetXmlDocument();
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="xmlFilePath">文件路径</param>
        /// <param name="xmlFilePathType">路径类型</param>
        public XmlDocHelper(string xmlFilePath, XmlPathType xmlFilePathType)
        {
            this.m_XmlFilePath = xmlFilePath;
            this.m_XmlFilePathType = xmlFilePathType;
            GetXmlDocument();
        }
        #endregion

        #region 获取XmlDocument对象
        /// <summary>
        /// 获取XmlDocument对象
        /// </summary>
        /// <returns></returns>
        private void GetXmlDocument()
        {
            if (this.m_XmlFilePathType == XmlPathType.AbsolutePath)
            {
                GetXmlDocumentFromFile(m_XmlFilePath);
            }
            else if (this.m_XmlFilePathType == XmlPathType.VirtualPath)
            {
                GetXmlDocumentFromFile(HttpContext.Current.Server.MapPath(m_XmlFilePath));
            }
        }

        /// <summary>
        /// 获取XmlDocument对象
        /// </summary>
        /// <param name="tempXmlFilePath">文件路径</param>
        /// <returns></returns>
        private void GetXmlDocumentFromFile(string tempXmlFilePath)
        {
            string xmlFileFullPath = tempXmlFilePath;
            xmlDoc.Load(xmlFileFullPath);
            //定义事件处理
            xmlDoc.NodeChanged += new XmlNodeChangedEventHandler(this.DealNodeUpdateEvent);
            xmlDoc.NodeInserted += new XmlNodeChangedEventHandler(this.DealNodeInsertEvent);
            xmlDoc.NodeRemoved += new XmlNodeChangedEventHandler(this.DealNodeDeleteEvent);
        }
        #endregion

        #region 处理Xml Node的事件
        /// <summary>
        /// 处理更新事件
        /// </summary>
        /// <param name="src"></param>
        /// <param name="args"></param>
        private void DealNodeUpdateEvent(Object src, XmlNodeChangedEventArgs args)
        {
            //保存设置
            //SaveXmlDocument();
        }

        /// <summary>
        /// 处理添加事件
        /// </summary>
        /// <param name="src"></param>
        /// <param name="args"></param>
        private void DealNodeInsertEvent(Object src, XmlNodeChangedEventArgs args)
        {
            //保存设置
            //SaveXmlDocument();
        }

        /// <summary>
        /// 处理删除事件
        /// </summary>
        /// <param name="src"></param>
        /// <param name="args"></param>
        private void DealNodeDeleteEvent(Object src, XmlNodeChangedEventArgs args)
        {
            //保存设置
            //SaveXmlDocument();
        }
        #endregion

        #region 保存XML文件
        public void SaveXmlDocument()
        {
            try
            {
                //保存设置的结果
                if (this.m_XmlFilePathType == XmlPathType.AbsolutePath)
                {
                    Savexml(m_XmlFilePath);
                }
                else if (this.m_XmlFilePathType == XmlPathType.VirtualPath)
                {
                    Savexml(HttpContext.Current.Server.MapPath(m_XmlFilePath));
                }
            }
            catch (XmlException xmle)
            {
                throw xmle;
            }
        }

        public void SaveXmlDocument(string xmlFilePath)
        {
            try
            {
                //保存设置的结果
                Savexml(xmlFilePath);
            }
            catch (XmlException xmle)
            {
                throw xmle;
            }
        }

        private void Savexml(string filepath)
        {
            xmlDoc.Save(filepath);
        }

        #endregion

        #region 读取指定节点的指定属性值
        /// <summary>
        /// 读取指定节点的指定属性值   
        /// </summary>
        /// <param name="nodeName">节点名称</param>
        /// <param name="attributeName">此节点的属性名称</param>
        /// <returns></returns>
        public string GetXmlNodeAttributeValue(string nodeName, string attributeName)
        {
            string strReturn = "";
            try
            {
                //根据指定路径获取节点
                XmlNode xmlNode = xmlDoc.SelectSingleNode(nodeName);
                if (!(xmlNode == null))
                {//获取节点的属性,并循环取出需要的属性值
                    XmlAttributeCollection xmlAttr = xmlNode.Attributes;

                    for (int i = 0; i < xmlAttr.Count; i++)
                    {
                        if (xmlAttr.Item(i).Name == attributeName)
                        {
                            strReturn = xmlAttr.Item(i).Value;
                            break;
                        }
                    }
                }
            }
            catch (XmlException xmle)
            {
                throw xmle;
            }
            return strReturn;
        }
        #endregion

        #region  读取指定节点的内容
        /// <summary>
        /// 读取指定节点的内容
        /// </summary>
        /// <param name="nodeName">节点名称</param>
        /// <returns></returns>
        public string GetXmlNodeValue(string nodeName)
        {
            string strReturn = String.Empty;
            try
            {
                //根据路径获取节点
                XmlNode xmlNode = xmlDoc.SelectSingleNode(nodeName);
                if (!(xmlNode == null))
                    strReturn = xmlNode.InnerText;
            }
            catch (XmlException xmle)
            {
                throw xmle;
            }
            return strReturn;
        }
        #endregion

        #region 批量为符合条件的节点进行付值

        /// <summary>
        /// 批量为符合条件的节点付值
        /// </summary>
        /// <param name="xmlNodePath">节点路径</param>
        /// <param name="xmlNodeValue">节点内容</param>
        public void SetMutilXmlNodeValue(string xmlNodePath, string xmlNodeValue)
        {
            try
            {
                XmlNodeList xmlNode = this.xmlDoc.SelectNodes(xmlNodePath);
                if (!(xmlNode == null))
                {
                    foreach (XmlNode xn in xmlNode)
                    {
                        xn.InnerText = xmlNodeValue;
                    }
                }
            }
            catch (XmlException xmle)
            {
                throw xmle;
            }
        }

        /// <summary>
        /// 批量为符合条件的节点的属性付值
        /// </summary>
        /// <param name="xmlNodePath"></param>
        /// <param name="xmlNodeAttribute"></param>
        /// <param name="xmlNodeAttributeValue"></param>
        public void SetMutilXmlNodeAttributeValue(string xmlNodePath, string xmlNodeAttribute, string xmlNodeAttributeValue)
        {
            try
            {
                XmlNodeList xmlNode = this.xmlDoc.SelectNodes(xmlNodePath);
                if (!(xmlNode == null))
                {
                    foreach (XmlNode xn in xmlNode)
                    {
                        XmlAttributeCollection xmlAttr = xn.Attributes;
                        for (int i = 0; i < xmlAttr.Count; i++)
                        {
                            if (xmlAttr.Item(i).Name == xmlNodeAttribute)
                            {
                                xmlAttr.Item(i).Value = xmlNodeAttributeValue;
                                break;
                            }
                        }
                    }
                }
            }
            catch (XmlException xmle)
            {
                throw xmle;
            }
        }

        #endregion

        #region 设置节点值
        /// <summary>
        /// 设置节点值
        /// </summary>
        /// <param name="xmlNodePath">节点路径</param>
        /// <param name="xmlNodeValue">节点内容</param>
        public void SetXmlNodeValue(string xmlNodePath, string xmlNodeValue)
        {
            try
            {
                //根据指定路径获取节点
                XmlNode xmlNode = xmlDoc.SelectSingleNode(xmlNodePath);
                //设置节点值
                if (!(xmlNode == null))
                    xmlNode.InnerText = xmlNodeValue;
            }
            catch (XmlException xmle)
            {
                throw xmle;
            }
        }


        public void SetXmlNodeValue(string xmlParentNodePath, string nodeName, string xmlNodeValue)
        {
            try
            {
                //根据指定路径获取节点
                XmlNode xmlParentNode = xmlDoc.SelectSingleNode(xmlParentNodePath);
                XmlNodeList XmlNodes = xmlParentNode.ChildNodes;
                XmlNode currentNode = null;

                if (XmlNodes != null && XmlNodes.Count > 0)
                {

                    for (int i = 0; i < XmlNodes.Count; i++)
                    {
                        XmlNode val = XmlNodes[i];
                        if (nodeName == val.Attributes["name"].Value)
                        {
                            currentNode = XmlNodes[i];
                            break;
                        }
                    }
                }


                if (currentNode != null)
                {
                    currentNode.InnerText = xmlNodeValue;
                }
            }
            catch (XmlException xmle)
            {
                throw xmle;
            }
        }
        #endregion

        #region 设置节点的属性值
        /// <summary>
        /// 设置节点的属性值
        /// </summary>
        /// <param name="xmlNodePath">节点路径</param>
        /// <param name="xmlNodeAttribute">节点属性</param>
        /// <param name="xmlNodeAttributeValue">节点属性值</param>
        public void SetXmlNodeAttributeValue(string xmlNodePath, string xmlNodeAttribute, string xmlNodeAttributeValue)
        {
            try
            {
                //根据指定路径获取节点
                XmlNode xmlNode = xmlDoc.SelectSingleNode(xmlNodePath);
                if (!(xmlNode == null))
                {
                    //获取节点的属性,并循环取出需要的属性值
                    XmlAttributeCollection xmlAttr = xmlNode.Attributes;
                    for (int i = 0; i < xmlAttr.Count; i++)
                    {
                        if (xmlAttr.Item(i).Name == xmlNodeAttribute)
                        {
                            xmlAttr.Item(i).Value = xmlNodeAttributeValue;
                            break;
                        }
                    }
                }
            }
            catch (XmlException xmle)
            {
                throw xmle;
            }
        }


        /// <summary>
        /// 给某个节点添加属性
        /// </summary>
        /// <param name="xmlNodePath">节点路径</param>
        /// <param name="xmlNodeAttributeList">要添加的属性及值对</param>
        public void SetXmlNodeAttributeValue(string xmlNodePath, Dictionary<string, string> xmlNodeAttributeList)
        {
            try
            {
                //根据指定路径获取节点
                XmlNode xmlNode = xmlDoc.SelectSingleNode(xmlNodePath);
                if (!(xmlNode == null))
                {
                    foreach (string attributeName in xmlNodeAttributeList.Keys)
                    {
                        XmlAttribute attribute = this.xmlDoc.CreateAttribute(attributeName);
                        attribute.Value = xmlNodeAttributeList[attributeName];
                        xmlNode.Attributes.Append(attribute);
                    }
                }
            }
            catch (XmlException xmle)
            {
                throw xmle;
            }
        }

        /// <summary>
        /// 给某个节点添加属性
        /// </summary>
        /// <param name="xmlNodePath">节点路径</param>
        /// <param name="xmlNodeAttributeList">要添加的属性及值对</param>
        public void SetXmlNodeAttributeValue(string xmlNodePath, Dictionary<string, double> xmlNodeAttributeList)
        {
            try
            {
                //根据指定路径获取节点
                XmlNode xmlNode = xmlDoc.SelectSingleNode(xmlNodePath);
                if (!(xmlNode == null))
                {
                    foreach (string attributeName in xmlNodeAttributeList.Keys)
                    {
                        XmlAttribute attribute = this.xmlDoc.CreateAttribute(attributeName);
                        attribute.Value = xmlNodeAttributeList[attributeName].ToString();
                        xmlNode.Attributes.Append(attribute);
                    }
                }
            }
            catch (XmlException xmle)
            {
                throw xmle;
            }
        }

        #endregion

        #region 添加节点
        /// <summary>
        /// 获取XML文件的根元素
        /// </summary>
        public XmlNode GetXmlRoot()
        {
            return xmlDoc.DocumentElement;
        }

        /// <summary>
        /// 在根节点下添加父节点
        /// </summary>
        public void AddParentNode(string parentNode)
        {
            try
            {
                XmlNode root = GetXmlRoot();
                XmlNode parentXmlNode = xmlDoc.CreateElement(parentNode);
                root.AppendChild(parentXmlNode);
            }
            catch (XmlException xmle)
            {
                throw xmle;
            }
        }

        /// <summary>
        /// 向一个已经存在的父节点中插入一个子节点
        /// </summary>
        /// <param name="parentNodePath">父节点</param>
        /// <param name="childNodePath">字节点名称</param>
        public void AddChildNode(string parentNodePath, string childnodename)
        {
            try
            {
                XmlNode parentXmlNode = xmlDoc.SelectSingleNode(parentNodePath);
                XmlNode childXmlNode = xmlDoc.CreateElement(childnodename);
                if (!((parentXmlNode) == null))//如果此节点存在
                {
                    parentXmlNode.AppendChild(childXmlNode);
                }
                else
                {
                    //如果不存在就放父节点添加
                    this.GetXmlRoot().AppendChild(childXmlNode);
                }
            }
            catch (XmlException xmle)
            {
                throw xmle;
            }
        }
        /// <summary>
        /// 向XML路径父节点中插入子节点油套压专用
        /// </summary>
        /// <param name="parentNodePath">要插入子节点的路径</param>
        /// <param name="DataTable">子节点集合</param>
        public void AddChildNodeForYTY(string parentNodePath, DataTable table)
        {
            try
            {
                XmlNode parentXmlNode = xmlDoc.SelectSingleNode(parentNodePath);
                XmlElement childXmlNode = xmlDoc.CreateElement("series");
                XmlElement childXmlNodeTmp = xmlDoc.CreateElement("series");
                childXmlNode.SetAttribute("name", "套压");
                childXmlNodeTmp.SetAttribute("name", "油压");
                XmlNode nodeTY = parentXmlNode.AppendChild(childXmlNode);
                XmlNode nodeYY = parentXmlNode.AppendChild(childXmlNodeTmp);
                foreach (DataRow row in table.Rows)
                {
                    XmlElement pointTY = xmlDoc.CreateElement("point");
                    XmlElement pointYY = xmlDoc.CreateElement("point");
                    if (row["TY"] != null)
                    {
                        pointTY.SetAttribute("name",Convert.ToDateTime(row["RQ"]).ToString("yyyy-MM-dd"));
                        pointTY.SetAttribute("y", row["TY"].ToString());
                    }
                    if (row["YY"] != null)
                    {
                        pointYY.SetAttribute("name", Convert.ToDateTime(row["RQ"]).ToString("yyyy-MM-dd"));
                        pointYY.SetAttribute("y", row["YY"].ToString());
                    }
                    nodeTY.AppendChild(pointTY);
                    nodeYY.AppendChild(pointYY);
                }
            }
            catch (XmlException xmle)
            {
                throw xmle;
            }
        }
        /// <summary>
        /// 向XML路径父节点中插入子节点油套压专用
        /// </summary>
        /// <param name="parentNodePath">要插入子节点的路径</param>
        /// <param name="DataTable">子节点集合</param>
        public void AddChildNodeForRCQ(string parentNodePath, DataTable table)
        {
            try
            {
                XmlNode parentXmlNode = xmlDoc.SelectSingleNode(parentNodePath);
                XmlElement childXmlNode = xmlDoc.CreateElement("series");
                childXmlNode.SetAttribute("name", "日产气");
                XmlNode nodeTY = parentXmlNode.AppendChild(childXmlNode);
                foreach (DataRow row in table.Rows)
                {
                    XmlElement pointRCQ = xmlDoc.CreateElement("point");
                    if (row["RCQ"] != null)
                    {
                        pointRCQ.SetAttribute("name", Convert.ToDateTime(row["RQ"]).ToString("yyyy-MM-dd"));
                        pointRCQ.SetAttribute("y", row["RCQ"].ToString());
                    }
                    nodeTY.AppendChild(pointRCQ);
                }
            }
            catch (XmlException xmle)
            {
                throw xmle;
            }
        }

        #region ----nan 2012-08-22 add begin----
        /// <summary>
        /// 向一个已经存在的父节点中插入一个子节点
        /// </summary>
        /// <param name="parentNodePath">父节点</param>
        /// <param name="childnodename">字节点名称</param>
        /// <param name="attributelist">字节点属性列表</param>
        public void AddChildNodeForAnyChartDataAll(string parentNodePath, DataTable table)
        {
            try
            {
                XmlNode parentXmlNode = xmlDoc.SelectSingleNode(parentNodePath);
                XmlElement childXmlNodeYY = xmlDoc.CreateElement("series");
                XmlElement childXmlNodeTY = xmlDoc.CreateElement("series");
                XmlElement childXmlNodeRCQ = xmlDoc.CreateElement("series");
                XmlElement childXmlNodeSCSJ = xmlDoc.CreateElement("series");
                //油压
                childXmlNodeYY.SetAttribute("name", "油压");
                childXmlNodeYY.SetAttribute("color", "Rgb(16,12,133)");//SetAttribute("color", "Rgb(46,122,171)");
                XmlNode nodeYY = parentXmlNode.AppendChild(childXmlNodeYY);
                //套压
                childXmlNodeTY.SetAttribute("name", "套压");
                childXmlNodeTY.SetAttribute("color", "Rgb(202,39,190)");//SetAttribute("color", "Rgb(225,45,235)");
                XmlNode nodeTY = parentXmlNode.AppendChild(childXmlNodeTY);

                //日产气
                childXmlNodeRCQ.SetAttribute("name", "日产气量");
                childXmlNodeRCQ.SetAttribute("y_axis", "extra_y_axis_1");
                childXmlNodeRCQ.SetAttribute("color", "Rgb(169,31,40)");//SetAttribute("color", "Rgb(255,255,0)");
                XmlNode nodeRCQ = parentXmlNode.AppendChild(childXmlNodeRCQ);
                //生产时间
                childXmlNodeSCSJ.SetAttribute("name", "生产时间");
                childXmlNodeSCSJ.SetAttribute("y_axis", "extra_y_axis_2");
                childXmlNodeSCSJ.SetAttribute("color", "Rgb(100,22,215)");
                XmlNode nodeSCSJ = parentXmlNode.AppendChild(childXmlNodeSCSJ);

                foreach (DataRow row in table.Rows)
                {
                    XmlElement pointTY = xmlDoc.CreateElement("point");
                    XmlElement pointYY = xmlDoc.CreateElement("point");
                    XmlElement pointRCQ = xmlDoc.CreateElement("point");
                    XmlElement pointSCSJ = xmlDoc.CreateElement("point");
                    if (row["TY"] != null)
                    {
                        pointTY.SetAttribute("name",Convert.ToDateTime(row["RQ"]).ToString("yyyy-MM-dd"));
                        pointTY.SetAttribute("y", row["TY"] == DBNull.Value ? "0" : row["TY"].ToString());
                    }
                    if (row["YY"] != null)
                    {
                        pointYY.SetAttribute("name", Convert.ToDateTime(row["RQ"]).ToString("yyyy-MM-dd"));
                        pointYY.SetAttribute("y", row["YY"] == DBNull.Value ? "0" : row["YY"].ToString());
                    }
                    if (row["RCQ"] != null)
                    {
                        pointRCQ.SetAttribute("name", Convert.ToDateTime(row["RQ"]).ToString("yyyy-MM-dd"));
                        pointRCQ.SetAttribute("y", row["RCQ"] == DBNull.Value ? "0" : row["RCQ"].ToString());
                    }
                    if (row["SCSJ"] != null)
                    {
                        pointSCSJ.SetAttribute("name", Convert.ToDateTime(row["RQ"]).ToString("yyyy-MM-dd"));
                        pointSCSJ.SetAttribute("y", row["SCSJ"] == DBNull.Value ? "0" : row["SCSJ"].ToString());
                    }
                    nodeTY.AppendChild(pointTY);
                    nodeYY.AppendChild(pointYY);
                    nodeRCQ.AppendChild(pointRCQ);
                    nodeSCSJ.AppendChild(pointSCSJ);
                }
            }
            catch (XmlException xmle)
            {
                throw xmle;
            }
        }

        public void AddChildNodeForChartStat(string parentNodePath, DataTable table)
        {
            try
            {
                XmlNode parentXmlNode = xmlDoc.SelectSingleNode(parentNodePath);
                XmlElement childXmlNodeWellCount = xmlDoc.CreateElement("series");
                XmlElement childXmlNodeCsCount = xmlDoc.CreateElement("series");
                XmlElement childXmlNodeConfirmCount = xmlDoc.CreateElement("series");
                XmlNode nodeWellCount = null;
                XmlNode nodeCsCount = null;
                XmlNode nodeConfirmCount = null;
                //总井数
                childXmlNodeWellCount.SetAttribute("name", "总井数");
                childXmlNodeWellCount.SetAttribute("color", "Rgb(16,12,133)");//SetAttribute("color", "Rgb(46,122,171)");
            
                nodeWellCount = parentXmlNode.AppendChild(childXmlNodeWellCount);
                //排查积液井数
                childXmlNodeCsCount.SetAttribute("name", "预警井数");
                childXmlNodeCsCount.SetAttribute("color", "Rgb(202,39,190)");
                nodeCsCount = parentXmlNode.AppendChild(childXmlNodeCsCount);

                //确认积液井数
                childXmlNodeConfirmCount.SetAttribute("name", "措施井数");
                childXmlNodeConfirmCount.SetAttribute("color", "Rgb(169,31,40)");
                nodeConfirmCount = parentXmlNode.AppendChild(childXmlNodeConfirmCount);

                foreach (DataRow row in table.Rows)
                {
                    XmlElement pointWellCount = xmlDoc.CreateElement("point");
                    XmlElement pointCsCount = xmlDoc.CreateElement("point");
                    XmlElement pointConfirmCount = xmlDoc.CreateElement("point");

                    if (null != row["wellcount"])
                    {
                        pointWellCount.SetAttribute("name", row["Name"].ToString());
                        pointWellCount.SetAttribute("y", row["wellcount"] == DBNull.Value ? "0" : row["wellcount"].ToString());
                    }

                    if (null != row["cscount"])
                    {
                        pointCsCount.SetAttribute("name", row["Name"].ToString());
                        pointCsCount.SetAttribute("y", row["cscount"] == DBNull.Value ? "0" : row["cscount"].ToString());
                    }

                    if (null != row["confirmcount"])
                    {
                        pointConfirmCount.SetAttribute("name", row["Name"].ToString());
                        pointConfirmCount.SetAttribute("y", row["confirmcount"] == DBNull.Value ? "0" : row["confirmcount"].ToString());
                    }

                    if (null != nodeWellCount)
                    {
                        nodeWellCount.AppendChild(pointWellCount);
                    }
                    if (null != nodeCsCount)
                    {
                        nodeCsCount.AppendChild(pointCsCount);
                    }

                    if (null != nodeConfirmCount)
                    {
                        nodeConfirmCount.AppendChild(pointConfirmCount);
                    }
                }
            }
            catch (XmlException ex)
            {
                
                throw ex;
            }
            
        }
        /// <summary>
        /// 生成措施优化统计柱形图
        /// </summary>
        /// <param name="parentNodePath"></param>
        /// <param name="table"></param>
        public void AddChildNodeForChartCsyhStat(string parentNodePath, DataTable table)
        {
            try
            {
                XmlNode parentXmlNode = xmlDoc.SelectSingleNode(parentNodePath);
                XmlElement childXmlNodeppCount = xmlDoc.CreateElement("series");
                XmlElement childXmlNodesdgzCount = xmlDoc.CreateElement("series");
                XmlElement childXmlNodezsqjCount = xmlDoc.CreateElement("series");
                XmlElement childXmlNodeqjCount = xmlDoc.CreateElement("series");
                XmlElement childXmlNodewlCount = xmlDoc.CreateElement("series");
                XmlNode nodeppCount = null;
                XmlNode nodesdgzCount = null;
                XmlNode nodezsqjCount = null;
                XmlNode nodeqjCount = null;
                XmlNode nodewlCount = null;
                //泡沫排水
                childXmlNodeppCount.SetAttribute("name", "泡沫排水");
                childXmlNodeppCount.SetAttribute("color", "Rgb(16,12,133)");
                nodeppCount = parentXmlNode.AppendChild(childXmlNodeppCount);
                //速度管柱
                childXmlNodesdgzCount.SetAttribute("name", "速度管柱");
                childXmlNodesdgzCount.SetAttribute("color", "Rgb(202,39,190)");
                nodesdgzCount = parentXmlNode.AppendChild(childXmlNodesdgzCount);

                //柱塞气举
                childXmlNodezsqjCount.SetAttribute("name", "柱塞气举");
                childXmlNodezsqjCount.SetAttribute("color", "Rgb(169,31,40)");
                nodezsqjCount = parentXmlNode.AppendChild(childXmlNodezsqjCount);
                //气举排水
                childXmlNodeqjCount.SetAttribute("name", "气举排水");
                childXmlNodeqjCount.SetAttribute("color", "Rgb(212,59,190)");
                nodeqjCount = parentXmlNode.AppendChild(childXmlNodeqjCount);

                //涡流排水
                childXmlNodewlCount.SetAttribute("name", "涡流排水");
                childXmlNodewlCount.SetAttribute("color", "Rgb(46,122,171)");
                nodewlCount = parentXmlNode.AppendChild(childXmlNodewlCount);

                foreach (DataRow row in table.Rows)
                {
                    XmlElement pointppCount = xmlDoc.CreateElement("point");
                    XmlElement pointsdgzCount = xmlDoc.CreateElement("point");
                    XmlElement pointzsqjCount = xmlDoc.CreateElement("point");
                    XmlElement pointqjCount = xmlDoc.CreateElement("point");
                    XmlElement pointwlCount = xmlDoc.CreateElement("point");

                    if (null != row["pp"] )
                    {
                        pointppCount.SetAttribute("name", row["Name"].ToString());
                        pointppCount.SetAttribute("y", row["pp"] == DBNull.Value ? "0" : row["pp"].ToString());
                    }

                    if (null != row["sdgz"] )
                    {
                        pointsdgzCount.SetAttribute("name", row["Name"].ToString());
                        pointsdgzCount.SetAttribute("y", row["sdgz"] == DBNull.Value ? "0" : row["sdgz"].ToString());
                    }

                    if (null != row["zsqj"])
                    {
                        pointzsqjCount.SetAttribute("name", row["Name"].ToString());
                        pointzsqjCount.SetAttribute("y", row["zsqj"] == DBNull.Value ? "0" : row["zsqj"].ToString());
                    }

                    if (null != row["qj"])
                    {
                        pointqjCount.SetAttribute("name", row["Name"].ToString());
                        pointqjCount.SetAttribute("y", row["qj"] == DBNull.Value ? "0" : row["qj"].ToString());
                    }

                    if (null != row["wl"])
                    {
                        pointwlCount.SetAttribute("name", row["Name"].ToString());
                        pointwlCount.SetAttribute("y", row["wl"] == DBNull.Value ? "0" : row["wl"].ToString());
                    }

                    if (null != nodeppCount)
                    {
                        nodeppCount.AppendChild(pointppCount);
                    }
                    if (null != nodesdgzCount)
                    {
                        nodesdgzCount.AppendChild(pointsdgzCount);
                    }

                    if (null != nodezsqjCount)
                    {
                        nodezsqjCount.AppendChild(pointzsqjCount);
                    }

                    if (null != nodeqjCount)
                    {
                        nodeqjCount.AppendChild(pointqjCount);
                    }

                    if (null != nodewlCount)
                    {
                        nodewlCount.AppendChild(pointwlCount);
                    }
                }
            }
            catch (XmlException ex)
            {

                throw ex;
            }

        }

        /// <summary>
        /// 生产增产气量柱形图
        /// </summary>
        /// <param name="parentNodePath"></param>
        /// <param name="table"></param>
        public void AddChildNodeZcqlForChartStat(string parentNodePath, DataTable table)
        {
            try
            {
                XmlNode parentXmlNode = xmlDoc.SelectSingleNode(parentNodePath);
                XmlElement childXmlNodeZcqlCount = xmlDoc.CreateElement("series");
                 XmlElement childXmlNodeCsCount = xmlDoc.CreateElement("series");
                 XmlElement childXmlNodeZjsCount = xmlDoc.CreateElement("series");
                XmlNode nodeZcqlCount = null;
                 XmlNode nodeCsCount = null;
                 XmlNode nodeZjsCount = null;

                 //总井数
                 childXmlNodeZjsCount.SetAttribute("name", "总井数");
                 childXmlNodeZjsCount.SetAttribute("color", "Rgb(16,12,133)");//SetAttribute("color", "Rgb(46,122,171)");

                 nodeZjsCount = parentXmlNode.AppendChild(childXmlNodeZjsCount);
                 //排查积液井数
                 childXmlNodeCsCount.SetAttribute("name", "措施井数");
                 childXmlNodeCsCount.SetAttribute("color", "Rgb(202,39,190)");
                 nodeCsCount = parentXmlNode.AppendChild(childXmlNodeCsCount);
                //增产气量
                childXmlNodeZcqlCount.SetAttribute("name", "增产气量");
                childXmlNodeZcqlCount.SetAttribute("y_axis", "extra_y_axis_1");
                childXmlNodeZcqlCount.SetAttribute("color", "Rgb(46,122,171)");

                nodeZcqlCount = parentXmlNode.AppendChild(childXmlNodeZcqlCount);
               

                foreach (DataRow row in table.Rows)
                {
                    XmlElement pointZcqlCount = xmlDoc.CreateElement("point");
                    XmlElement pointZjsCount = xmlDoc.CreateElement("point");
                    XmlElement pointCsCount = xmlDoc.CreateElement("point");

                    if (null != row["zjs"])
                    {
                        pointZjsCount.SetAttribute("name", row["Name"].ToString());
                        pointZjsCount.SetAttribute("y", row["zjs"] == DBNull.Value ? "0" : row["zjs"].ToString());
                    }

                    if (null != row["csjs"])
                    {
                        pointCsCount.SetAttribute("name", row["Name"].ToString());
                        pointCsCount.SetAttribute("y", row["csjs"] == DBNull.Value ? "0" : row["csjs"].ToString());
                    }
                    if (null != row["zcql"])
                    {
                        pointZcqlCount.SetAttribute("name", row["Name"].ToString());
                        pointZcqlCount.SetAttribute("y", row["zcql"] == DBNull.Value ? "0" : row["zcql"].ToString());
                    }


                    if (null != nodeZjsCount)
                    {
                        nodeZjsCount.AppendChild(pointZjsCount);
                    }
                    if (null != nodeCsCount)
                    {
                        nodeCsCount.AppendChild(pointCsCount);
                    }

                    if (null != nodeZcqlCount)
                    {
                        nodeZcqlCount.AppendChild(pointZcqlCount);
                    }
                    
                }
            }
            catch (XmlException ex)
            {

                throw ex;
            }

        }

        /// <summary>
        /// 向一个已经存在的父节点中插入一个子节点
        /// </summary>
        /// <param name="parentNodePath">父节点</param>
        /// <param name="childnodename">字节点名称</param>
        /// <param name="attributelist">字节点属性列表</param>
        /// <param name="qxType">曲线类型</param>
        public void AddChildNodeForAnyChartDataAll(string parentNodePath, DataTable table, string qxType)
        {
            try
            {
                XmlNode parentXmlNode = xmlDoc.SelectSingleNode(parentNodePath);
                XmlElement childXmlNodeYY = xmlDoc.CreateElement("series");
                XmlElement childXmlNodeTY = xmlDoc.CreateElement("series");
                XmlElement childXmlNodeRCQ = xmlDoc.CreateElement("series");
                XmlElement childXmlNodeSCSJ = xmlDoc.CreateElement("series");
                XmlNode nodeYY = null;
                XmlNode nodeTY = null;
                XmlNode nodeRCQ = null;
                XmlNode nodeSCSJ=null;
                switch (qxType)
                {
                    case "YYRCQ":
                        {
                            //油压
                            childXmlNodeYY.SetAttribute("name", "油压");
                            childXmlNodeYY.SetAttribute("color", "Rgb(16,12,133)");//SetAttribute("color", "Rgb(46,122,171)");
                            nodeYY = parentXmlNode.AppendChild(childXmlNodeYY);
                            //套压
                            childXmlNodeTY.SetAttribute("name", "套压");
                            childXmlNodeTY.SetAttribute("color", "Rgb(202,39,190)");//SetAttribute("color", "Rgb(225,45,235)");
                            nodeTY = parentXmlNode.AppendChild(childXmlNodeTY);

                            //日产气
                            childXmlNodeRCQ.SetAttribute("name", "日产气量");
                            childXmlNodeRCQ.SetAttribute("y_axis", "extra_y_axis_1");
                            childXmlNodeRCQ.SetAttribute("color", "Rgb(169,31,40)");//SetAttribute("color", "Rgb(255,255,0)");
                            nodeRCQ = parentXmlNode.AppendChild(childXmlNodeRCQ);
                        }
                        break;
                    case "YYSCSJ":
                        {
                            //油压
                            childXmlNodeYY.SetAttribute("name", "油压");
                            childXmlNodeYY.SetAttribute("color", "Rgb(16,12,133)");//SetAttribute("color", "Rgb(46,122,171)");
                            nodeYY = parentXmlNode.AppendChild(childXmlNodeYY);
                            //套压
                            childXmlNodeTY.SetAttribute("name", "套压");
                            childXmlNodeTY.SetAttribute("color", "Rgb(202,39,190)");//SetAttribute("color", "Rgb(225,45,235)");
                            nodeTY = parentXmlNode.AppendChild(childXmlNodeTY);

                            //生产时间
                            childXmlNodeSCSJ.SetAttribute("name", "生产时间");
                            childXmlNodeSCSJ.SetAttribute("y_axis", "extra_y_axis_2");
                            childXmlNodeSCSJ.SetAttribute("color", "Rgb(100,22,215)");
                            nodeSCSJ = parentXmlNode.AppendChild(childXmlNodeSCSJ);
                        }
                        break;
                    case "RCQSCSJ":
                        { 
                            //日产气
                            childXmlNodeRCQ.SetAttribute("name", "日产气量");
                            childXmlNodeRCQ.SetAttribute("y_axis", "extra_y_axis_1");
                            childXmlNodeRCQ.SetAttribute("color", "Rgb(169,31,40)");//SetAttribute("color", "Rgb(255,255,0)");
                            nodeRCQ = parentXmlNode.AppendChild(childXmlNodeRCQ);
                            //生产时间
                            childXmlNodeSCSJ.SetAttribute("name", "生产时间");
                            childXmlNodeSCSJ.SetAttribute("y_axis", "extra_y_axis_2");
                            childXmlNodeSCSJ.SetAttribute("color", "Rgb(100,22,215)");
                            nodeSCSJ = parentXmlNode.AppendChild(childXmlNodeSCSJ);
                        }
                        break;
                }
           

                foreach (DataRow row in table.Rows)
                {
                    XmlElement pointTY = xmlDoc.CreateElement("point");
                    XmlElement pointYY = xmlDoc.CreateElement("point");
                    XmlElement pointRCQ = xmlDoc.CreateElement("point");
                    XmlElement pointSCSJ = xmlDoc.CreateElement("point");
                    if (row["TY"] != null)
                    {
                        pointTY.SetAttribute("name", Convert.ToDateTime(row["RQ"]).ToString("yyyy-MM-dd"));
                        pointTY.SetAttribute("y", row["TY"] == DBNull.Value ? "0" : row["TY"].ToString());
                    }
                    if (row["YY"] != null)
                    {
                        pointYY.SetAttribute("name", Convert.ToDateTime(row["RQ"]).ToString("yyyy-MM-dd"));
                        pointYY.SetAttribute("y", row["YY"] == DBNull.Value ? "0" : row["YY"].ToString());
                    }
                    if (row["RCQ"] != null)
                    {
                        pointRCQ.SetAttribute("name", Convert.ToDateTime(row["RQ"]).ToString("yyyy-MM-dd"));
                        pointRCQ.SetAttribute("y", row["RCQ"] == DBNull.Value ? "0" : row["RCQ"].ToString());
                    }
                    if (row["SCSJ"] != null)
                    {
                        pointSCSJ.SetAttribute("name", Convert.ToDateTime(row["RQ"]).ToString("yyyy-MM-dd"));
                        pointSCSJ.SetAttribute("y", row["SCSJ"] == DBNull.Value ? "0" : row["SCSJ"].ToString());
                    }
                    switch (qxType)
                    {
                        case "YYRCQ":
                            {
                                if(null!=nodeTY)
                                    nodeTY.AppendChild(pointTY);
                                if(null!=nodeYY)
                                   nodeYY.AppendChild(pointYY);
                                if(null!=nodeRCQ)
                                  nodeRCQ.AppendChild(pointRCQ);  
                            }
                            break;
                        case "YYSCSJ":
                            {
                                if(null!=nodeTY)
                                    nodeTY.AppendChild(pointTY);
                                if(null!=nodeYY)
                                   nodeYY.AppendChild(pointYY);
                                if(null!=nodeSCSJ)
                                   nodeSCSJ.AppendChild(pointSCSJ);
                            }
                            break;
                        case "RCQSCSJ":
                            {
                                if(null!=nodeRCQ)
                                  nodeRCQ.AppendChild(pointRCQ);
                                if(null!=nodeSCSJ)
                                  nodeSCSJ.AppendChild(pointSCSJ);
                            }
                            break;
                    }
                    //nodeTY.AppendChild(pointTY);
                    //nodeYY.AppendChild(pointYY);
                    //nodeRCQ.AppendChild(pointRCQ);
                    //nodeSCSJ.AppendChild(pointSCSJ);
                }
            }
            catch (XmlException xmle)
            {
                throw xmle;
            }
        }

        /// <summary>
        /// 给某个节点添加属性
        /// </summary>
        /// <param name="xmlNodePath">节点路径</param>
        /// <param name="xmlNodeAttributeList">要添加的属性及值对</param>
        public void SetXmlNodeAttributeValueScale(string xmlNodePath, Dictionary<string, string> xmlNodeAttributeList)
        {
            try
            {
                //根据指定路径获取节点
                XmlNode xmlNode = xmlDoc.SelectSingleNode(xmlNodePath);
                XmlNode ParentNode = xmlNode.ParentNode;
                if (!(xmlNode == null))
                {
                    if ("extra_y_axis_2" == ParentNode.NextSibling.Attributes["name"].Value)
                    {
                        XmlNode node = ParentNode.NextSibling.FirstChild;
                        foreach (string attributeName in xmlNodeAttributeList.Keys)
                        {

                            XmlAttribute attribute = this.xmlDoc.CreateAttribute(attributeName);
                            attribute.Value = xmlNodeAttributeList[attributeName];
                            node.Attributes.Append(attribute);
                        }
                    }
                }
            }
            catch (XmlException xmle)
            {
                throw xmle;
            }
        }


        /// <summary>
        /// 向一个已经存在的父节点中插入一个子节点
        /// </summary>
        /// <param name="parentNodePath">父节点</param>
        /// <param name="childnodename">字节点名称</param>
        /// <param name="attributelist">字节点属性列表</param>
        public void AddChildNodeForAnyChartDataEffusion(string parentNodePath, DataTable table,string qxType)
        {
            try
            {
                XmlNode parentXmlNode = xmlDoc.SelectSingleNode(parentNodePath);
                XmlNode nodeSCJS = null;
                XmlNode nodeKJS = null;
                XmlNode nodeRCQ = null;
                XmlNode nodeCYL = null;
                XmlNode nodeLNLJCQ = null;

                switch (qxType)
                {
                    case "wellcount":
                        {
                            XmlElement childXmlNodeSCJS = xmlDoc.CreateElement("series");
                            XmlElement childXmlNodeKJS = xmlDoc.CreateElement("series");
                            //生产井数
                            childXmlNodeSCJS.SetAttribute("name", "生产井数");
                            childXmlNodeSCJS.SetAttribute("color", "Rgb(46,45,171)");
                            nodeSCJS = parentXmlNode.AppendChild(childXmlNodeSCJS);
                            //开井数
                             childXmlNodeKJS.SetAttribute("name", "开井数");
                            childXmlNodeKJS.SetAttribute("color", "Rgb(202,39,190)");//SetAttribute("color", "Rgb(225,45,235)");
                            nodeKJS = parentXmlNode.AppendChild(childXmlNodeKJS);
                        }
                        break;
                    case "cql":
                        {
                            XmlElement childXmlNodeRCQ = xmlDoc.CreateElement("series");
                            XmlElement childXmlNodeCYL = xmlDoc.CreateElement("series");
                            
                            //日产气
                            childXmlNodeRCQ.SetAttribute("name", "日产气量");
                            childXmlNodeRCQ.SetAttribute("color", "Rgb(169,31,40)");//SetAttribute("color", "Rgb(255,255,0)");
                            nodeRCQ = parentXmlNode.AppendChild(childXmlNodeRCQ);
                            //产液量
                            childXmlNodeCYL.SetAttribute("name", "产液量");
                            childXmlNodeCYL.SetAttribute("color", "Rgb(0,0,255)");
                            nodeCYL = parentXmlNode.AppendChild(childXmlNodeCYL);

                           
                        }
                        break;
                    default:
                        XmlElement childXmlNodeLNLJCQ = xmlDoc.CreateElement("series");
                        //历年累计产气量
                        childXmlNodeLNLJCQ.SetAttribute("name", "历年累计产气量");
                        childXmlNodeLNLJCQ.SetAttribute("color", "Rgb(169,31,40)");//SetAttribute("color", "Rgb(255,255,0)");
                        nodeLNLJCQ = parentXmlNode.AppendChild(childXmlNodeLNLJCQ);
                        break;
                }
                

                foreach (DataRow row in table.Rows)
                {
                    XmlElement pointSCJS = xmlDoc.CreateElement("point");
                    XmlElement pointKJS = xmlDoc.CreateElement("point");
                    XmlElement pointRCQ = xmlDoc.CreateElement("point");
                    XmlElement pointCYL = xmlDoc.CreateElement("point");
                    XmlElement pointLNLJCQ = xmlDoc.CreateElement("point");
                    string curDateStr = row["RQ"] == DBNull.Value ? DateTime.Now.ToString("yyyy-MM-dd") : Convert.ToDateTime(row["RQ"]).ToString("yyyy-MM-dd");
                    if (row["WELLCOUNT"] != null)
                    {
                        pointSCJS.SetAttribute("name",curDateStr);
                        pointSCJS.SetAttribute("y", row["WELLCOUNT"] == DBNull.Value ? "0" : row["WELLCOUNT"].ToString());
                    }
                    if (row["KJCOUNT"] != null)
                    {
                        pointKJS.SetAttribute("name",curDateStr);
                        pointKJS.SetAttribute("y", row["KJCOUNT"] == DBNull.Value ? "0" : row["KJCOUNT"].ToString());
                    }
                    if (null != row["RCQ"])
                    {
                        pointRCQ.SetAttribute("name", curDateStr);
                        pointRCQ.SetAttribute("y", row["RCQ"] == DBNull.Value ? "0" : row["RCQ"].ToString());
                    }
                    if (null != row["RCS"])
                    {
                        pointCYL.SetAttribute("name", curDateStr);
                        pointCYL.SetAttribute("y", row["RCS"] == DBNull.Value ? "0" : row["RCS"].ToString());
                    }
                    if (null != row["LNLJCQL"])
                    {
                        pointLNLJCQ.SetAttribute("name", curDateStr);
                        pointLNLJCQ.SetAttribute("y", row["LNLJCQL"] == DBNull.Value ? "0" : row["LNLJCQL"].ToString());
                    }
                    //if (row["NISSAN"] != null)
                    //{
                    //    pointRCQ.SetAttribute("name", row["TJDATE"].ToString());
                    //    pointRCQ.SetAttribute("y", row["NISSAN"] == DBNull.Value ? "0" : row["NISSAN"].ToString());
                    //}
                    //if (row["LIQUIDYIELD"] != null)
                    //{
                    //    pointCYL.SetAttribute("name", row["TJDATE"].ToString());
                    //    pointCYL.SetAttribute("y", row["LIQUIDYIELD"] == DBNull.Value ? "0" : row["LIQUIDYIELD"].ToString());
                    //}
                    //if (row["TOTALGAS"] != null)
                    //{
                    //    pointLNLJCQ.SetAttribute("name", row["TJDATE"].ToString());
                    //    pointLNLJCQ.SetAttribute("y", row["TOTALGAS"] == DBNull.Value ? "0" : row["TOTALGAS"].ToString());
                    //}


                    switch (qxType)
                    {
                        case "wellcount":
                            {
                                nodeSCJS.AppendChild(pointSCJS);
                                nodeKJS.AppendChild(pointKJS);
                            }
                            break;
                        case "cql":
                            {
                                nodeRCQ.AppendChild(pointRCQ);
                                nodeCYL.AppendChild(pointCYL);
                            }
                            break;
                        default:
                            nodeLNLJCQ.AppendChild(pointLNLJCQ);
                            break;
                    }

                }
            }
            catch (XmlException xmle)
            {
                throw xmle;
            }
        }

        /// <summary>
        /// 向一个已经存在的父节点中插入一个子节点
        /// </summary>
        /// <param name="parentNodePath">父节点</param>
        /// <param name="childnodename">字节点名称</param>
        /// <param name="attributelist">字节点属性列表</param>
        /// <param name="qxType">曲线类型</param>
        public void AddChildNodeForAnyChartLQQX(string parentNodePath, DataTable table, string qxType)
        {
            try
            {
                XmlNode parentXmlNode = xmlDoc.SelectSingleNode(parentNodePath);
                XmlNode nodeZJS = null;
                XmlNode nodeKJS = null;
                XmlNode nodeYY = null;
                XmlNode nodeTY = null;
                XmlNode nodeCQL = null;
                XmlNode nodeLYL = null;
                XmlNode nodeSL = null;

                switch (qxType)
                {
                    case "wellcount":
                        {
                            XmlElement childXmlNodeZJS = xmlDoc.CreateElement("series");
                            XmlElement childXmlNodeKJS = xmlDoc.CreateElement("series");
                            //生产井数
                            childXmlNodeZJS.SetAttribute("name", "生产井数");
                            childXmlNodeZJS.SetAttribute("color", "Rgb(46,45,171)");
                            nodeZJS = parentXmlNode.AppendChild(childXmlNodeZJS);
                            //开井数
                            childXmlNodeKJS.SetAttribute("name", "开井数");
                            childXmlNodeKJS.SetAttribute("color", "Rgb(202,39,190)");//SetAttribute("color", "Rgb(225,45,235)");
                            nodeKJS = parentXmlNode.AppendChild(childXmlNodeKJS);
                        }
                        break;
                    case "yty":
                        {
                            XmlElement childXmlNodeYY= xmlDoc.CreateElement("series");
                            XmlElement childXmlNodeTY = xmlDoc.CreateElement("series");

                            //油压
                            childXmlNodeYY.SetAttribute("name", "油压");
                            childXmlNodeYY.SetAttribute("color", "Rgb(225,45,225)");
                            nodeYY = parentXmlNode.AppendChild(childXmlNodeYY);
                            //套压
                            childXmlNodeTY.SetAttribute("name", "套压");
                            childXmlNodeTY.SetAttribute("color", "Rgb(0,0,255)");
                            nodeTY= parentXmlNode.AppendChild(childXmlNodeTY);


                        }
                        break;
                    case "lyl":
                        {
                            XmlElement childXmlNodeLYL = xmlDoc.CreateElement("series");
                            XmlElement childXmlNodeSL = xmlDoc.CreateElement("series");

                            //利用率
                            childXmlNodeLYL.SetAttribute("name", "利用率");
                            childXmlNodeLYL.SetAttribute("color", "Rgb(225,45,225)");
                            nodeLYL = parentXmlNode.AppendChild(childXmlNodeLYL);
                            //时率
                            childXmlNodeSL.SetAttribute("name", "时率");
                            childXmlNodeSL.SetAttribute("color", "Rgb(0,0,255)");
                            nodeSL = parentXmlNode.AppendChild(childXmlNodeSL);
                        }
                        break;
                    default:
                        XmlElement childXmlNodeCQL = xmlDoc.CreateElement("series");
                        //产气量
                        childXmlNodeCQL.SetAttribute("name", "产气量");
                        childXmlNodeCQL.SetAttribute("color", "Rgb(169,31,40)");//SetAttribute("color", "Rgb(255,255,0)");
                        nodeCQL = parentXmlNode.AppendChild(childXmlNodeCQL);
                        break;
                }


                foreach (DataRow row in table.Rows)
                {
                    XmlElement pointZJS = xmlDoc.CreateElement("point");
                    XmlElement pointKJS = xmlDoc.CreateElement("point");
                    XmlElement pointYY = xmlDoc.CreateElement("point");
                    XmlElement pointTY = xmlDoc.CreateElement("point");
                    XmlElement pointCQL = xmlDoc.CreateElement("point");
                    XmlElement pointLYL = xmlDoc.CreateElement("point");
                    XmlElement pointSL = xmlDoc.CreateElement("point");
                    string curDateStr = row["TS"].ToString();
                    if (null!=row["ZJS"])
                    {
                        pointZJS.SetAttribute("name", curDateStr);
                        pointZJS.SetAttribute("y", row["ZJS"] == DBNull.Value ? "0" : row["ZJS"].ToString());
                    }
                    if (null!=row["KJS"])
                    {
                        pointKJS.SetAttribute("name", curDateStr);
                        pointKJS.SetAttribute("y", row["KJS"] == DBNull.Value ? "0" : row["KJS"].ToString());
                    }
                    if (null != row["YY"])
                    {
                        pointYY.SetAttribute("name", curDateStr);
                        pointYY.SetAttribute("y", row["YY"] == DBNull.Value ? "0" : row["YY"].ToString());
                    }
                    if (null != row["TY"])
                    {
                        pointTY.SetAttribute("name", curDateStr);
                        pointTY.SetAttribute("y", row["TY"] == DBNull.Value ? "0" : row["TY"].ToString());
                    }
                    if (null != row["RCQ"])
                    {
                        pointCQL.SetAttribute("name", curDateStr);
                        pointCQL.SetAttribute("y", row["RCQ"] == DBNull.Value ? "0" : row["RCQ"].ToString());
                    }
                    if (null != row["qjlyl"])
                    {
                        pointLYL.SetAttribute("name", curDateStr);
                        pointLYL.SetAttribute("y", row["qjlyl"] == DBNull.Value ? "0" : row["qjlyl"].ToString());
                    }
                    if (null != row["kjsl"])
                    {
                        pointSL.SetAttribute("name", curDateStr);
                        pointSL.SetAttribute("y", row["kjsl"] == DBNull.Value ? "0" : row["kjsl"].ToString());
                    }

                    switch (qxType)
                    {
                        case "wellcount":
                            {
                                nodeZJS.AppendChild(pointZJS);
                                nodeKJS.AppendChild(pointKJS);
                            }
                            break;
                        case "yty":
                            {
                                nodeYY.AppendChild(pointYY);
                                nodeTY.AppendChild(pointTY);
                            }
                            break;
                        case "lyl":
                            {
                                nodeLYL.AppendChild(pointLYL);
                                nodeSL.AppendChild(pointSL);
                            }
                            break;
                        default:
                            nodeCQL.AppendChild(pointCQL);
                            break;
                    }

                }
            }
            catch (XmlException xmle)
            {
                throw xmle;
            }
        }


        /// <summary>
        /// 向一个已经存在的父节点中插入一个子节点
        /// </summary>
        /// <param name="parentNodePath">父节点</param>
        /// <param name="childnodename">字节点名称</param>
        /// <param name="attributelist">字节点属性列表</param>
        /// <param name="qxType">曲线类型</param>
        public void AddChildNodeForAnyChartFNDQXDB(string parentNodePath, DataTable table, string qxType,string Name,string color)
        {
            try
            {
                XmlNode parentXmlNode = xmlDoc.SelectSingleNode(parentNodePath);
                
                XmlNode nodeTY = null;

                XmlNode nodeRCQ= null;


                switch (qxType)
                {
                    case "TY":
                        {
                            XmlElement childXmlNodeTY= xmlDoc.CreateElement("series");
                            //XmlElement childXmlNodeTY1 = xmlDoc.CreateElement("series");
                            //XmlElement childXmlNodeTY2 = xmlDoc.CreateElement("series");
                            //套压
                            childXmlNodeTY.SetAttribute("name", Name);
                            childXmlNodeTY.SetAttribute("color",color);
                            nodeTY = parentXmlNode.AppendChild(childXmlNodeTY);
                           
                        }
                        break;
                    case "RCQ":
                        {
                            XmlElement childXmlNodeRCQ = xmlDoc.CreateElement("series");
                            
                            //日产气量
                            childXmlNodeRCQ.SetAttribute("name", Name);
                            childXmlNodeRCQ.SetAttribute("color", "Rgb(169,31,40)");//SetAttribute("color", "Rgb(255,255,0)");
                            nodeRCQ = parentXmlNode.AppendChild(childXmlNodeRCQ);
                          
                        }
                        break;
                    default:
                        break;
                }


                foreach (DataRow row in table.Rows)
                {
                    XmlElement pointTY = xmlDoc.CreateElement("point");
                    
                    XmlElement pointRCQ = xmlDoc.CreateElement("point");


                    string curDateStr = row["RQ"]==DBNull.Value?string.Empty:Convert.ToDateTime(row["RQ"].ToString()).ToString("yyyy-MM-dd");
                    if (null != row["TY"])
                    {
                        pointTY.SetAttribute("name", curDateStr);
                        pointTY.SetAttribute("y", row["TY"] == DBNull.Value ? "0" : row["TY"].ToString());
                    }
                   
                    if (null != row["RCQ"])
                    {
                        pointRCQ.SetAttribute("name", curDateStr);
                        pointRCQ.SetAttribute("y", row["RCQ"] == DBNull.Value ? "0" : row["RCQ"].ToString());
                    }
                    
                   


                    switch (qxType)
                    {
                        case "TY":
                            {
                                nodeTY.AppendChild(pointTY);
                            }
                            break;
                        case "RCQ":
                            {
                                nodeRCQ.AppendChild(pointRCQ);
                            }
                            break;
                        default:
                            break;
                    }

                }
            }
            catch (XmlException xmle)
            {
                throw xmle;
            }
        }

        /// <summary>
        /// 向一个已经存在的父节点中插入一个子节点
        /// </summary>
        /// <param name="parentNodePath">父节点</param>
        /// <param name="childnodename">字节点名称</param>
        /// <param name="attributelist">字节点属性列表</param>
        /// <param name="qxType">曲线类型</param>
        public void AddChildNodeForAnyChartLQQXDB(string parentNodePath, DataTable table, string qxType, string Name, string color)
        {
            try
            {
                XmlNode parentXmlNode = xmlDoc.SelectSingleNode(parentNodePath);

                XmlNode nodeTY = null;

                XmlNode nodeRCQ = null;


                switch (qxType)
                {
                    case "TY":
                        {
                            XmlElement childXmlNodeTY = xmlDoc.CreateElement("series");
                            //XmlElement childXmlNodeTY1 = xmlDoc.CreateElement("series");
                            //XmlElement childXmlNodeTY2 = xmlDoc.CreateElement("series");
                            //套压
                            childXmlNodeTY.SetAttribute("name", Name);
                            childXmlNodeTY.SetAttribute("color", color);
                            nodeTY = parentXmlNode.AppendChild(childXmlNodeTY);

                        }
                        break;
                    case "RCQ":
                        {
                            XmlElement childXmlNodeRCQ = xmlDoc.CreateElement("series");

                            //日产气量
                            childXmlNodeRCQ.SetAttribute("name", Name);
                            childXmlNodeRCQ.SetAttribute("color", "Rgb(169,31,40)");//SetAttribute("color", "Rgb(255,255,0)");
                            nodeRCQ = parentXmlNode.AppendChild(childXmlNodeRCQ);

                        }
                        break;
                    default:
                        break;
                }


                foreach (DataRow row in table.Rows)
                {
                    XmlElement pointTY = xmlDoc.CreateElement("point");

                    XmlElement pointRCQ = xmlDoc.CreateElement("point");


                    string curDateStr = row["TS"].ToString();
                    if (null != row["TY"])
                    {
                        pointTY.SetAttribute("name", curDateStr);
                        pointTY.SetAttribute("y", row["TY"] == DBNull.Value ? "0" : row["TY"].ToString());
                    }

                    if (null != row["RCQ"])
                    {
                        pointRCQ.SetAttribute("name", curDateStr);
                        pointRCQ.SetAttribute("y", row["RCQ"] == DBNull.Value ? "0" : row["RCQ"].ToString());
                    }




                    switch (qxType)
                    {
                        case "TY":
                            {
                                nodeTY.AppendChild(pointTY);
                            }
                            break;
                        case "RCQ":
                            {
                                nodeRCQ.AppendChild(pointRCQ);
                            }
                            break;
                        default:
                            break;
                    }

                }
            }
            catch (XmlException xmle)
            {
                throw xmle;
            }
        }
        #endregion ---end----

        /// <summary>
        /// 向一个已经存在的父节点中插入一个子节点
        /// </summary>
        /// <param name="parentNodePath">父节点</param>
        /// <param name="childnodename">字节点名称</param>
        /// <param name="attributelist">字节点属性列表</param>
        public void AddChildNodeForAnyChartData(string parentNodePath, string childnodename, Dictionary<string, string> attributelist)
        {
            try
            {
                XmlNode parentXmlNode = xmlDoc.SelectSingleNode(parentNodePath);

                foreach (string attributename in attributelist.Keys)
                {
                    XmlNode childXmlNode = xmlDoc.CreateElement(childnodename);
                    XmlAttribute nodeNameAttribute = this.xmlDoc.CreateAttribute("name");
                    nodeNameAttribute.Value =Convert.ToDateTime(attributename).ToString("yyyy-MM-dd");
                    childXmlNode.Attributes.Append(nodeNameAttribute);
                    XmlAttribute nodeValueAttribute = this.xmlDoc.CreateAttribute("y");
                    nodeValueAttribute.Value = attributelist[attributename];
                    childXmlNode.Attributes.Append(nodeValueAttribute);
                    if (!((parentXmlNode) == null))//如果此节点存在
                    {
                        parentXmlNode.AppendChild(childXmlNode);
                    }
                }
            }
            catch (XmlException xmle)
            {
                throw xmle;
            }
        }

        /// <summary>
        /// 向一个已经存在的父节点中插入一个子节点
        /// </summary>
        /// <param name="parentNodePath">父节点</param>
        /// <param name="childnodename">字节点名称</param>
        /// <param name="attributelist">字节点属性列表</param>
        public void AddChildNodeForAnyChartData(string parentNodePath, string childnodename, Dictionary<string, double> attributelist)
        {
            try
            {
                XmlNode parentXmlNode = xmlDoc.SelectSingleNode(parentNodePath);

                foreach (string attributename in attributelist.Keys)
                {
                    XmlNode childXmlNode = xmlDoc.CreateElement(childnodename);
                    XmlAttribute nodeNameAttribute = this.xmlDoc.CreateAttribute("name");
                    nodeNameAttribute.Value = attributename;
                    childXmlNode.Attributes.Append(nodeNameAttribute);
                    XmlAttribute nodeValueAttribute = this.xmlDoc.CreateAttribute("y");
                    nodeValueAttribute.Value = attributelist[attributename].ToString();
                    childXmlNode.Attributes.Append(nodeValueAttribute);
                    if (!((parentXmlNode) == null))//如果此节点存在
                    {
                        parentXmlNode.AppendChild(childXmlNode);
                    }
                }
            }
            catch (XmlException xmle)
            {
                throw xmle;
            }
        }

        /// <summary>
        /// 向一个已经存在的父节点中插入一个子节点
        /// </summary>
        /// <param name="parentNodePath">父节点</param>
        /// <param name="childnodename">字节点名称</param>
        /// <param name="attributelist">字节点属性列表</param>
        public void AddChildNodeData(string parentNodePath, string childnodename, Dictionary<string, string> attributelist)
        {
            try
            {
                XmlNode parentXmlNode = xmlDoc.SelectSingleNode(parentNodePath);
                XmlNode childXmlNode = xmlDoc.CreateElement(childnodename);
                foreach (string attributename in attributelist.Keys)
                {
                    
                    XmlAttribute nodeAttribute = this.xmlDoc.CreateAttribute(attributename);
                    nodeAttribute.Value = attributelist[attributename].ToString();
                    childXmlNode.Attributes.Append(nodeAttribute);
                    if (!((parentXmlNode) == null))//如果此节点存在
                    {
                        parentXmlNode.AppendChild(childXmlNode);
                    }
                }
            }
            catch (XmlException xmle)
            {
                throw xmle;
            }
        }

        /// <summary>
        /// 向一个已经存在的父节点中插入一个子节点--生成anychart图专用
        /// ---李京都
        /// </summary>
        /// <param name="parentNodePath">父节点</param>
        /// <param name="childnodename">字节点名称</param>
        /// <param name="attributelist">字节点属性列表</param>
        public void AddChildNode(string parentNodePath, string childnodename, Dictionary<string, string> attributelist)
        {
            try
            {
                XmlNode parentXmlNode = xmlDoc.SelectSingleNode(parentNodePath);
                XmlNodeList XmlNodes = parentXmlNode.ChildNodes;
                XmlElement childXmlNode = xmlDoc.CreateElement(childnodename);

                foreach (KeyValuePair<string, string> tmp in attributelist)
                {
                    childXmlNode.SetAttribute(tmp.Key, tmp.Value);
                }
                string xmlInfo = "<label enabled=\"True\" multi_line_align=\"Center\" position=\"Far\" padding=\"5\"><font bold=\"false\" color=\"Black\"/>";
                xmlInfo += string.Format("<format>{0}</format>", attributelist["text"]);
                xmlInfo += "<background enabled=\"true\">";
                xmlInfo += " <corners type=\"Rounded\" all=\"3\"/><fill type=\"Solid\" color=\"White\" opacity=\"1\"/>";
                xmlInfo += "<inside_margin left=\"0\" top=\"0\" right=\"0\" bottom=\"0\"/></background></label>";
                childXmlNode.InnerXml = xmlInfo;
                parentXmlNode.AppendChild(childXmlNode);
            }
            catch (XmlException xmle)
            {
                throw xmle;
            }
        }

        /// <summary>
        /// 向一个已经存在的父节点中插入一个子节点
        /// </summary>
        /// <param name="parentNodePath">父节点</param>
        /// <param name="childnodename">字节点名称</param>
        /// <param name="attributelist">字节点属性列表</param>
        public void AddChildNode(string parentNodePath, string childnodename, string attribute, Dictionary<string, string> attributelist)
        {
            try
            {
                XmlNode parentXmlNode = xmlDoc.SelectSingleNode(parentNodePath);
                XmlNodeList XmlNodes = parentXmlNode.ChildNodes;
                XmlNode childXmlNode = xmlDoc.CreateElement(attribute);

                if (XmlNodes != null && XmlNodes.Count > 0)
                {

                    for (int i = 0; i < XmlNodes.Count; i++)
                    {
                        XmlNode val = XmlNodes[i];
                        if (childnodename == val.Attributes["name"].Value)
                        {
                            parentXmlNode = XmlNodes[i];
                            break;
                        }
                    }
                }

                if (childXmlNode != null)
                {
                    foreach (string attributename in attributelist.Keys)
                    {
                        XmlAttribute nodeAttribute = this.xmlDoc.CreateAttribute(attributename);
                        nodeAttribute.Value = attributelist[attributename];
                        childXmlNode.Attributes.Append(nodeAttribute);
                        parentXmlNode.AppendChild(childXmlNode);
                    }

                }

            }
            catch (XmlException xmle)
            {
                throw xmle;
            }
        }

     
       
        /// <summary>
        /// 向一个节点添加属性
        /// </summary>
        /// <param name="NodePath">节点路径</param>
        /// <param name="NodeAttribute">属性名</param>
        public void AddAttribute(string NodePath, string NodeAttribute)
        {
            privateAddAttribute(NodePath, NodeAttribute, "");
        }

        private void privateAddAttribute(string NodePath, string NodeAttribute, string NodeAttributeValue)
        {
            try
            {
                XmlNode nodePath = xmlDoc.SelectSingleNode(NodePath);
                if (!(nodePath == null))
                {
                    XmlAttribute nodeAttribute = this.xmlDoc.CreateAttribute(NodeAttribute);
                    nodeAttribute.Value = NodeAttributeValue;
                    nodePath.Attributes.Append(nodeAttribute);
                }
            }
            catch (XmlException xmle)
            {
                throw xmle;
            }
        }

        /// <summary>
        ///  向一个节点添加属性,并付值
        /// </summary>
        /// <param name="NodePath">节点</param>
        /// <param name="NodeAttribute">属性名</param>
        /// <param name="NodeAttributeValue">属性值</param>
        public void AddAttribute(string NodePath, string NodeAttribute, string NodeAttributeValue)
        {
            privateAddAttribute(NodePath, NodeAttribute, NodeAttributeValue);
        }
        #endregion

        #region 删除节点
        /// <summary>
        /// 删除节点的一个属性
        /// </summary>
        /// <param name="NodePath">节点所在的xpath表达式</param>
        /// <param name="NodeAttribute">属性名</param>
        public void DeleteAttribute(string NodePath, string NodeAttribute)
        {
            XmlNodeList nodePath = this.xmlDoc.SelectNodes(NodePath);
            if (!(nodePath == null))
            {
                foreach (XmlNode tempxn in nodePath)
                {
                    XmlAttributeCollection xmlAttr = tempxn.Attributes;
                    for (int i = 0; i < xmlAttr.Count; i++)
                    {
                        if (xmlAttr.Item(i).Name == NodeAttribute)
                        {
                            tempxn.Attributes.RemoveAt(i);
                            break;
                        }
                    }
                }
            }
        }

        /// <summary>
        /// 删除节点,当其属性值等于给定的值时
        /// </summary>
        /// <param name="NodePath">节点所在的xpath表达式</param>
        /// <param name="NodeAttribute">属性</param>
        /// <param name="NodeAttributeValue"></param>
        public void DeleteAttribute(string NodePath, string NodeAttribute, string NodeAttributeValue)
        {
            XmlNodeList nodePath = this.xmlDoc.SelectNodes(NodePath);
            if (!(nodePath == null))
            {
                foreach (XmlNode tempxn in nodePath)
                {
                    XmlAttributeCollection xmlAttr = tempxn.Attributes;
                    for (int i = 0; i < xmlAttr.Count; i++)
                    {
                        if (xmlAttr.Item(i).Name == NodeAttribute && xmlAttr.Item(i).Value == NodeAttributeValue)
                        {
                            tempxn.Attributes.RemoveAt(i);
                            break;
                        }
                    }
                }
            }
        }
        /// <summary>
        /// 删除节点
        /// </summary>
        /// <param name="tempXmlNode"></param>
        /// <remarks></remarks>
        public void DeleteXmlNode(string tempXmlNode)
        {
            XmlNodeList nodePath = this.xmlDoc.SelectNodes(tempXmlNode);
            if (!(nodePath == null))
            {
                foreach (XmlNode xn in nodePath)
                {
                    xn.ParentNode.RemoveChild(xn);
                }
            }
        }

        #endregion

    }

 

 

posted on 2013-10-28 17:33  杨锐  阅读(243)  评论(0)    收藏  举报