如题,谢谢!!

解决方案 »

  1.   

    look into System.Xml.XmlProcessingInstruction class, you should be able to change its  property after you obtain the node in DocumentElement's ChildNodes
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemxmlxmldocumentclasscreateprocessinginstructiontopic.asp
      

  2.   

    XmlDocument x = new XmlDocument();
    x.Load(Server.MapPath("x.xml"));
    for(int i = 0; i<x.ChildNodes.Count-1;i++)
    {if(x.ChildNodes[i].NodeType == XmlNodeType.ProcessingInstruction)
    {
    x.ChildNodes[i].ParentNode.RemoveChild(x.ChildNodes[i]);
    XmlNode node = x.CreateProcessingInstruction("xml-stylesheet", "type='text/xsl' href='data.xsl'");
    x.InsertAfter(node,x.FirstChild);
    break;
    }
    }
    x.Save(Server.MapPath("x.xml"));