实名认证用户熊川湘 身份证号码430811198506290914

给xml某个节点赋值

 int Tnodej = 0;//节点位置临时存储变量

        /// <summary>
        /// 给特定node节点赋值
        /// </summary>
        /// <param name="nodename">要查找的节点名称</param>
        /// <param name="xn">开始查找的节点源</param>
        /// <param name="text">要赋值的内容</param>
        /// <param name="i">0表示给所有的赋值,数据几点表给第几个赋值</param>
        protected void GetNode(string nodename, XmlNode xn, string text, int i)
        {
            XmlNode endnode = null;
            endnode = xn;
            if (endnode.Name != nodename)
            {

                XmlNodeList NodeChildList = xn.ChildNodes;
                foreach (XmlNode nls in NodeChildList)
                {
                    GetNode(nodename, nls, text, i);
                }
            }
            else
            {


                if (i != 0)
                {
                    if (Tnodej == i)
                    {
                        xn.InnerText = text;
                    }
                    Tnodej++;
                }
                else
                {
                    xn.InnerText = text;
                }

            }


        }

posted @ 2010-04-12 14:30  浪达短信群发  阅读(910)  评论(0编辑  收藏  举报