本文介绍了SelectNodes和GetElementsByTagName的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SelectNodes和GetElementsByTagName之间的主要区别是什么?

what are main differences between SelectNodes and GetElementsByTagName.

推荐答案

是一个.NET / MSXML特定的方法,可以获取一个表达式。 XPath可以通过标签名称选择元素,但也可以执行许多其他更复杂的选择规则。

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.

是一种DOM级别1的核心标准方法,可用于许多语言(但拼写为首都 G 。净)。它只通过标签名称选择元素;您不能要求它选择具有某个属性的元素,或者标记名为 a 的元素包含标签名称 b 或任何聪明的东西。它更老,更简单,在某些环境中更快。

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.

这篇关于SelectNodes和GetElementsByTagName的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-11 18:07