using System;using System.Collections.Generic;using System.Text;using System.Xml;using System.Collections; namespace namednodemap{ class Program { static void Main(string[] args) { XmlDocument doc = new XmlDocument(); doc.LoadXml("<book genre='novel' publicationdate='1997'><title>pride and prejudice</title></book>"); XmlAttributeCollection attrcoll = doc.DocumentElement.Attributes; XmlAttribute attr = (XmlAttribute)attrcoll.GetNamedItem("genre"); attr.Value = "fiction"; Console.WriteLine(doc.OuterXml); } }}

评论