解决方案 »

  1.   

    WriteProcessingInstruction这个方法有没有重载,选择追加位置?
      

  2.   

    writer.WriteStartDocument(); //添加此行
    writer.WriteProcessingInstruction("xml-stylesheet", "type=\"text/xsl\" href=\"form/record.xsl\"");
      

  3.   

    这样不行的,Serialize方法本来就自动添加了<?xml version="1.0" encoding="utf-8"?>,如果再写WriteStartDocument就变成了这样:
    <?xml version="1.0" encoding="utf-8"?><?xml-stylesheet type="text/xsl" href="form/record.xsl"?><?xml version="1.0" encoding="utf-8"?>
      

  4.   

    换个思路,读出xml,在<?xml version="1.0" encoding="utf-8"?>之后插入
    <?xml-stylesheet type="text/xsl" href="form/index2.xsl"?>
      

  5.   

    找一个折中的方法,在你所要序列化的类中添加一个字符串字段,
    [XmlText]
    public string styleShee="<?xml-stylesheet type="text/xsl" href="form/record.xsl"?>"
    如果还不行,那就自己控制序列化过程。
      

  6.   

    问题解决了 参照这里
    http://www.cnblogs.com/fish-li/archive/2013/05/05/3061816.html