谢谢大家了~~最好能说说代码怎么写~~!!

解决方案 »

  1.   

    XmlNode node =....你获得的当前节点string a=node.LastChild.Value;
    属性获取方法
    string b=node.LastChild.Attribte["name"].value;
      

  2.   

    XmlDocument xmldoc = new XmlDocument();
    xmldoc.Load(filename); XmlNodeList topM=xmldoc.DocumentElement.ChildNodes;
    foreach(XmlElement element in topM)
    {
    if(element.Name=="appSettings")
    {
    XmlNodeList _node=element.ChildNodes;
    if(_node.Count >0)
    {
    foreach(XmlElement el in _node)
    {
    if(el.Attributes["key"].Value == "DBConnectionString")
    {
    el.Attributes["value"].Value = WebConigConnection;
    // string ss = @"D:\DBCustomAction.txt";
    // DateTime end = DateTime.Now;
    // StreamWriter ExecuteDmozTime = File.AppendText(ss);
    // ExecuteDmozTime.WriteLine("WebConigConnection:");
    // ExecuteDmozTime.WriteLine(end.ToString());
    // ExecuteDmozTime.WriteLine(WebConigConnection);
    // ExecuteDmozTime.WriteLine("filename:");
    // ExecuteDmozTime.WriteLine(filename);
    // ExecuteDmozTime.Flush();
    // ExecuteDmozTime.Close(); }
    }
    }
    }
    }
    xmldoc.Save(filename);
    楼主参考下,不过好像有个lastnote 属性,楼主可以参考参考
      

  3.   

    对应的,
    web.config<appSettings>
        <add key="day" value="0" />
        <add key="hour" value="6" />
        <add key="min" value="10" />
    </appSettings>
    不知道对楼主有帮助没
      

  4.   

    怎样获取xml中当前节点的的最后一个子节点的属性值  
    得到这个属性之后,我要把它当成一个整型的数,进行+1运算
    大家快点帮帮我呀~~~
    怎么就没人会呢?
      

  5.   

    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.IO;
    using System.Xml;
    namespace XmlNode1
    {   
        public class Sample
        {
            public static void Main()
            {
                XmlDocument doc = new XmlDocument();
                doc.LoadXml("<book xmlns:bk='urn:samples' bk:ISBN='1-861001-57-5'>" +
                            "<title>Pride And Prejudice</title>" +"<title>有点困了</title>" 
                            +"<title 无聊='相当无聊' 吃了么='没吃呢'>Pride And Prejudice</title>"+ 
                            "</book>");
                XmlNode root = doc.FirstChild;
                //Create a new attribute.
                string ns = root.GetNamespaceOfPrefix("bk");
                XmlNode attr = doc.CreateNode(XmlNodeType.Attribute, "genre", ns);
                attr.Value = "novel";
                //Add the attribute to the document.
                root.Attributes.SetNamedItem(attr);
                Console.WriteLine("Display the modified XML...");
                doc.Save(Console.Out);
                Console.ReadLine();
    //---------------------------------------------------
                XmlNode node = doc.SelectSingleNode("book");
                XmlNode lastNode = node.LastChild;
                XmlAttributeCollection attributes = lastNode.Attributes;
                foreach (XmlAttribute xa in attributes)
                {
                    Console.WriteLine("属性名字:  "+ xa.Name + "     " +"属性值:  "+ xa.Value);
                }
                Console.ReadLine();
    //---------------------------------------------------
            }
        }
    }
    调试通过.自己可以修改下.其中//---------------------------------------------------中间的为寻找节点,及其最后一个子节点.并把其属性显示.
    自己读取建立对应的XmlDocument ,然后操作.