I am using in our project, so that we can display any other HTML in our system. I ran into my unit test on this issue, and want to make sure that I am not doing anything wrong if I have an image, and it has 2 "src" values, then I want to choose it, both of them Remove, and add back to the right path once more. I do not think it will be with our HTML, but just in case ....
So, here is an example image tag:
Here's the code to manipulate HTML: public static string fixHMMLinks (this string html) {var htmlDoc = new HtmlDocument () {OptionWriteEmptyNodes = true}; HtmlDoc.LoadHtml (HTML); Var ImagesToCheck = htmlDoc.DocumentNode.SelectNodes ("// img [@src! = '']"); Var image (var src = image.GetAttributeValue ("src", string.Empty); if (Uri. ISFFMmlRustring (src, UriKind.Relative)) {if the (null! = ImagesToCheck) {foreach (imagesToCheck.ToList ()) { image.Attributes.Remove ( "src"); Image.SetAttributeValue ( "src", Stringkformet (RELATIVE_IMAGE_PROTOCOL_AND_HOST, src));} else if (Urikaisvelafuaruarstring (src, UriKind.Absolute)) {image.Attributes.Remove ( "src"); Image.SetAttributeValue ( "src", src.Replace (ABSOLUTE_IMAGE_HOST_TO_REPLACE, IMAGE_PROTOCOL_AND_HOST));}}} Return htmlDoc.DocumentNode.OuterHtml;} when I debug And this line "removes the image quality." ("Src"); ", there are 2" src "values, as up Damage after the line, although there is one would assume "src", which begins with "/ knowledge", I was asked to summarize the expected removal of them have since been removed:
By removing a feature from the list, using its name. If there are more than one feature by this name, then all of them will be deleted.
I have checked for HtmlAttributeCollection in CodePlex, and remove method takes you through a loop to remove value
I use it wrong Am I doing this, or did I have the opportunity to give a patch to HTMLAgilitpack?
confirmed: image.Attributes.Remove only remove the first event gives. Remove multiple times to call a quick improvement. If it is called and the attribute is not found, then it does not do anything.
You may want to know about it by HtmlAgilityPack authors.
No comments:
Post a Comment