ImportNode creates empty xmlns attribute

后端 未结 6 1919
误落风尘
误落风尘 2021-02-20 08:34

Regrading this code:

   var tmpNewNode = xdoc.ImportNode(newNode, true);

    if (oldNode.ParentNode != null)
    {
        oldNode.ParentNode.ReplaceChild(tmpNe         


        
6条回答
  •  猫巷女王i
    2021-02-20 08:55

    Finally i solved this opening xml file and replace all ocurrences of xmlns "" with a empty string.

    Maybe its not elegant solution but its simple and works fine.

    //remove void xmlns
    File.WriteAllText(filename, Regex.Replace(File.ReadAllText(filename), "xmlns=\"\"", ""));
    

提交回复
热议问题