-
-
Notifications
You must be signed in to change notification settings - Fork 390
Open
Description
1. Description
I've got the following value
<a download href=\"/downloads/arquivo.zip\">Download do Arquivo</a>
When I pass this into the following method in order to add the target="_blank"
attributte, I'm getting this:
<a download="" href=\"/downloads/arquivo.zip\" target=\"_blank\">Download do Arquivo</a>
How can I prevent the lib to add the empty value on download
?
Here is the method.
private string UpdateAnchorTagsWithTargetBlank(string html)
{
var doc = new HtmlDocument();
doc.LoadHtml(html);
var anchorNodes = doc.DocumentNode.SelectNodes("//a[@href]");
if (anchorNodes != null)
{
foreach (var node in anchorNodes)
{
if (node.GetAttributeValue("target", "") != "_blank")
node.SetAttributeValue("target", "_blank");
}
}
return doc.DocumentNode.OuterHtml;
}
2. Exception
Not applicable
3. Fiddle or Project
Not applicable
4. Any further technical details
- HtmlAgilityPack (1.11.40)
- SDK Version: 6.0.404
elgonzo
Metadata
Metadata
Assignees
Labels
No labels