diff --git a/src/HtmlAgilityPack.Shared/HtmlDocument.cs b/src/HtmlAgilityPack.Shared/HtmlDocument.cs index b58dac1b..e32bb3a3 100644 --- a/src/HtmlAgilityPack.Shared/HtmlDocument.cs +++ b/src/HtmlAgilityPack.Shared/HtmlDocument.cs @@ -681,7 +681,7 @@ public HtmlNode GetElementbyId(string id) throw new Exception(HtmlExceptionUseIdAttributeFalse); } - return Nodesid.ContainsKey(id) ? Nodesid[id] : null; + return Nodesid.TryGetValue(id, out var value) ? value : null; } /// @@ -1769,7 +1769,7 @@ private void Parse() // https://www.w3schools.com/jsref/prop_node_innertext.asp // textContent returns the text content of all elements, while innerText returns the content of all elements, except for