SelectNodes and GetElementsByTagName

Jason picture Jason · Mar 25, 2010 · Viewed 7.9k times · Source

what are main differences between SelectNodes and GetElementsByTagName.

Answer

bobince picture bobince · Mar 25, 2010

SelectNodes is a .NET/MSXML-specific method that gets a list of matching nodes for an XPath expression. XPaths can select elements by tag name but can also do lots of other, more complicated selection rules.

getElementByTagName is a DOM Level 1 Core standard method available in many languages (but spelled with a capital G in .NET). It selects elements only by tag name; you can't ask it to select elements with a certain attribute, or elements with tag name a inside other elements with tag name b or anything clever like that. It's older, simpler, and in some environments faster.