Use the following XML document to describe the XPath Syntax:
Locate a node:The XML document can be viewed as a node tree (similar to a computer tree folder ).XPath uses pattern expressions to recognize nodes in XML documents. An XPATH mode is a list of child element names separated by diagonal lines to describe a path
When using dom4j, we cannot obtain an element across layers. it must be obtained at one layer, which is very troublesome.
Why xpath?
When using dom4j, we cannot obtain an element across layers. it must be obtained at one layer, which is very troublesome.Therefore, we can use the xpath technology to access a node more conveniently, which allows us to conveniently read the specified node.
this:This XML file represents the reseller. The dealer is a node, and the dealer "inside" is a node that represents the onboard inventory. The dealer is the "parent" of the car node, and the car node is the "child". Then there are branches underneath the car node that produce the "Kids" node. Each vehicle node forms a "sibling" relationship. In this example, there is a tree-multi-attribute relationship. property enables the intrinsic characteristics of a particular node. You'll notice that each
Chapter 4: XPath syntax
ArticleAuthor: A Jie
4. XPath syntax As we have mentioned earlier, XPath is a language used to help XSLT search for location information in XML so
4.XPath of syntaxAs we mentioned earlier, XPath is the language used to help XSLT find positioning information in an XML source document. In actual use, XPath and XSLT are always mixed together, and in the syntax examples in the previous chapter we already have the syntax to
XPath is the XML query language, which is similar to SQL. The XML below is used as an example to introduce the XPath syntax.
Locate a node XML is a tree structure, similar to the structure of the data folder in the file system. XPath is similar to the path naming method in the file sys
4. XPath syntax
As we have mentioned earlier, XPath is a language used to help XSLT search for location information in XML source documents. In actual use, XPath and XSLT are always used together. In the above chapter, we have used the XPath
I've been on it before. NET operation of XML, but not very detailed, now I will explain how C # to operate XML files, just as learning to operate the database to learn the SQL language, before learning to manipulate XML and language, we need to familiarize ourselves with XML "SQL" statement XPath. Since the purpose of this series of posts is not to introduce the XPath s
The specific learning of XPath can be viewed through the viewing (link: http://www.w3school.com.cn/xpath/index.asp)Here is just the usual use of a few tables posted, later query:Here's the XPath I personally feel like selectors that havesyntax +XPath axis operation + operator + functionSeveral combinations are used.A l
XPath example
This topic reviews the syntax examples in the entire XPath reference. All examples are based on the example XML file of xpath syntax appended to this section.
Expression reference./AuthorAll AuthorAll First. NameAll /BookstoreThe document elements of this docum
XPath syntax is still very powerful, support some functions and operators, convenient operation, but because of the version of the possible functions can only be used in XPath2 (2007), and not in XPath1 (1999), such as function Ends-with ( String).
XPath syntax in the selection of DOM object search is very useful,
I have also sent a message about. net, but it is not very detailed. Now I will introduce in detail how to operate XML files in C #, just like learning to operate a database and learn the SQL language, before learning to operate XML and the language, we need to familiarize ourselves with the XML "SQL" Statement XPath. Since this series of posts does not aim to introduce the XPath
This topic reviews the syntax examples in the entire XPath reference. All examples are example XML files (inventory. xml) based on the XPath syntax ). For an example of using an XPath expression in the test file, see the "Union (|) Example" at the end of this topic ".
long as one boss + several core members. But this requires long-term cooperation in order to produce such a core of leadership.Soldiers are not more than the fine, this truth is difficult to understand before, and recently began to have a profound experience. A team of dozens of people, if it is a mob, is far from the efficiency of the lean team of 10 people.Increasing the number of people will increase the cost of internal communication. If the boss does not have a strong personal charisma and
4.4 function Functions there are many function Functions in XPath that can help us find the desired node accurately. Count () function: counts the number of nodes that meet the condition. Example: pxsl: value-ofselect = "count (PERSON [name = tom] 4.4 function (Functions)
There are many functional functions in XPath that can help us find the desired node accurately.
Count () Efficacy
Purpose: count the nu
Grammar
4.4 Functional Functions (functions)There are many functional functions in XPath that can help us pinpoint the nodes we need.Count () featureFunction: Statistics count, returns the number of nodes that meet the criteria.For example: Description: The purpose of the code is to display the name attribute value for the person element as Tom has several.Number () featureAction: Converts the text in the value of a property to a numeric value.Exampl
XPath syntax:
Locating the root tag
/down Level Search
/text () Extract text content
/@xxx Extract Attribute Contents
Sample:Import requestsfrom lxml Import etreefor i in range (1): URL = "http://www.xxx.com/topic/tv/page/{}". Format (i)
req = Requests.get (URL). Content HTML = etree. HTML (req) # extract Text = Html.xpath ( '/html/body/section/div[1]/div/article[*]/he
Everyday Italian Giada De Laurentiis 2005 30.00 Harry Potter J K. Rowling 2005 29.99 XQuery Kick Start James McGovern Per Bothner Kurt Cagle James Linn Vaidyanathan Nagarajan 2003 49.99 Learning XML Erik T. Ray 2003 39.95
The above is the BookStore. xml file
Start processing
XDocument xdoc = XDocument.Load(); XElement xroot = xdoc.Root; Console.WriteLine(xroot.Name); IEnumerabl
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.