I have a function that reads an HTML file and returns the value as a string, however, the string output contains a backslash whenever there are quotes in the HTML attributes.
Function:
public string Get(string page)
{
var doc = new HtmlAgilityPack.HtmlDocument();
doc.LoadHtml(page);
var content = doc.DocumentNode.SelectSingleNode("//html");
return content;
}
Output:
<head>
<title>Page Title</title>
<meta charset=\"UTF-8\">
<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">
<link rel=\"stylesheet\" href=\"url\"
</head>
Desired Output:
<head>
<title>Page Title</title>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="stylesheet" href="url"
</head>
Is there a way to remove the backslashes that appear in the attributes tags? I have tried using replace but it doesn't work, I have also tried HttpUtility.HtmlDecode but both don't seem to work