<book xmlns="">haoshu</UserName>
后面多了个 xmlns="" 我怎么才能把他去掉?我的添加方法是:
 XmlElement newElement = xmlDoc.CreateElement(ElementName);
 newElement.InnerText = ElementText;
 root1.AppendChild(newElement);

解决方案 »

  1.   

    XmlDocument doc = new XmlDocument();
        doc.Load("xmlFile");          //Create an attribute collection and remove an attribute
        //from the collection.
        XmlAttributeCollection attrColl = doc.DocumentElement.Attributes;
        attrColl.RemoveAt(0);
      

  2.   

    xmlDoc.CreateElement(ElementName,“urn-MyServer-Books”);urn-MyServer-Books为父元素的namespaceURI 
      
    *****************************************************************************
    欢迎使用CSDN论坛阅读器 : CSDN Reader(附全部源代码) 
    http://www.cnblogs.com/feiyun0112/archive/2006/09/20/509783.html
      

  3.   

    我知道那个是父元素的uri ,可是我想把他去掉。每个根节点都有这么一个,二级节点就没有了,不知道为什么
      

  4.   

    把你的xml文件内容贴出来看下...
      

  5.   

    是代码还是生成好的xml文件?
      

  6.   

    有原Xml文件吗?有的话,就把原xml文件和代码都贴出来看看..
      

  7.   

    搞顶了,我在写xml根的时候加了xmlns的连接。下面的就都有了