Xpath learning notes and xpath Learning
I recently reviewed my previous year's textbooks and thought about the software I wanted to write a diary at that time.
If you want to do it, you can use the console to write one. Once you do it, there is no bug. During this period, you can use Xpath to read data, so you just learned a little.
Take notes in this way to consolidate the learning process. By the way, if you forget it, you can come back and check it out.
This article is not too detailed and is enough for me to use.
For more information, see.
Xpath is a recognized search expression in the XML world.
This expression uses the path method (similar to the path Representation Method Used in the URL) to address each part of the XML document.
Xpath is the XML query language used to retrieve information contained in XML document nodes.
Common characters in Xpath are as follows:
. Used to reference the current node itself. For example, all the child nodes of the root node.
.. Indicates the parent node of the current node
[] Indicates a specific element in an ordered sequence, for example, life/day [2] indicates a subnode of the second day under the life node.
@ Indicates the node attribute. For example, @ price indicates the attribute named price, that is, the attribute and value in the tag.
/Indicates that the node is selected from the root node. It is also used for the interval between nodes and subnodes. For example,/life indicates that all subnodes under the life node are selected, which is equivalent ., /life/day indicates all subnodes of day under the life Node
// Indicates to query the entire xml file, regardless of the current node location. For example, // day indicates all day nodes, and // day/time indicates all time nodes whose parent nodes are day.
* Wildcard characters indicating the path. For example,/day/* indicates all child nodes of the day node.
| Indicates the logic or, used to obtain the node Union, for example, // day | // day [2] indicates all B nodes and c nodes
Example:
Because I am using the SelectSingleNode Method
This method returns only the first child node that matches the parameter, so only one path of all the same-level nodes is returned.
For beginners, please point out what is wrong.
If you want to learn more, you can read this article, which is very detailed and easy to understand.
Http://www.cnblogs.com/yukaizhao/archive/2011/07/25/xpath.html
Reprinted please contact