Before you start writing, let’s review the difference between elements and nodes:
Theelement is one of the most widely used nodes in the W3C Document Object Model (DOM).
elements have associated "properties".
The XmlElement class has many methods to access its "attributes" (GetAttribute, SetAttribute, RemoveAttribute, GetAttributeNode, etc.).
You can also use the "Attributes" attribute to return an "XML attribute set" that supports "name" or "serial number" access.
So, from the explanation of the XmlElement class, we can easily know the difference between the XmlNode and XmlElement classes:
The XmlElement class is a node that only has "properties", while XmlNode is a node that not only has "properties" but also has "child nodes".
So, when we use them, if you need to get or set the innerText or innerXml in the node, then you need to use XmlNode; and if you need to get or set the attributes (parameters) of the node itself At that time, you need to use XmlElement. Of course, you can also use (XmlElement) to convert XmlNode.
Now let’s get to the main topic
In JavaScript, except for the id selector, which is easier to select, the rest are not easy to select. jquery is much better in this area and provides many acquisition methods, including
1. Basic selectors (mainly including tag selector, id selector, class selector, universal selector, group selector)
$("#divId") Gets the element with ID divId
$("a") Gets all elements
$(".bgRed") Get the element whose CSS class is bgRed
$("*") gets all elements of the page
$("#divId, a, .bgRed") gets three selectors that meet the conditions
2. Hierarchical selectors (mainly including child element selectors, descendant element selectors, immediate sibling element selectors, and adjacent sibling element selectors)
2.1 Child element selector> ===============Select child element
2.2 The descendant selector directly uses spaces to indicate that it includes not only sons but also grandsons...================ Select descendant elements