0

私はHtmlAgilityPackhtmlドキュメントの解析に使用していますが、次のような子要素を置き換えたり削除したりすると、次のようになります。

        string TargetPath = Path.Combine(Server.MapPath("/Views/SaveChange"),
        User.Identity.Name + "Test.cshtml");

        HtmlDocument ndoc = new HtmlDocument();
        ndoc.Load(TargetPath);

        ndoc.DocumentNode.RemoveChild(ndoc.GetElementbyId("id"), false);
        ndoc.save(TargetPath);

これを行った後、Test.cshtmlファイルを開くと、すべての終了タグが閉じられなくなります。

before removing child => <img .. />
after removing child => <img ..>

誰かがここで何が問題なのか教えてもらえますか?

4

0 に答える 0