Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
C# で書かれた小さなテキスト エディターがあります。
HTML ファイル (既に実行済み) をプレーン テキストで開き、開始タグと終了タグが正しいことを確認する必要があります。たとえば、これがある場合:
<body> Text </body>それは正しいと言うべきですが、私が持って<body> <body>いるなら、それは間違っていると言うべきです。
<body> Text </body>
<body> <body>
HTML Agility Pack または C# の正規表現でこれを取得する方法はありますか?
public bool IsCorrectHtml(string html) { var htmlDocument = new HtmlDocument(); htmlDocument.LoadHtml(html); var parseErrors = htmlDocument.ParseErrors; return !parseErrors.Any(); // return true if no error. }