[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: XmlElement.GetChildrenByFilter not selecting correct child


On 5/11/25 2:37 PM, Lee wrote:
I am trying to get the <tbody> element of a table. But .GetChildrenByFilter("table > tbody") selects the <thead> element instead. That same CSS selector tested with two different online testers works as expected, so I think it is correct. But, I could be wrong.

Is this a bug?

Demo project attached.



I see that "thead" matches "tbody":

[code]
Public Sub Main()

  Dim sHtml As String = File.Load("./test.html")
  Dim hDoc As New HtmlDocument
  Dim hElement As XmlElement
  Dim aAllChildNodes As XmlNode[]

  hDoc.HtmlFromString(sHtml)

  aAllChildNodes = hDoc.GetElementById("target_div").AllChildNodes
  For Each hChildNode As XmlNode In aAllChildNodes
    If hChildNode.IsElement Then
      hElement = hChildNode
      Print hElement.Name, hElement.MatchFilter("table > tbody")
    Endif
  Next

End
[/code]

Result in Console:
table   False
thead   True
tbody   True
tr      False
td      False


--
Lee

--- Gambas User List Netiquette [https://gambaswiki.org/wiki/doc/netiquette] ----
--- Gambas User List Archive [https://lists.gambas-basic.org/archive/user] ----


References:
XmlElement.GetChildrenByFilter not selecting correct childLee <t.lee.davidson@xxxxxxxxx>