XML in the network age, XML files play a role in the preservation and transmission of data. SOAP protocols communicate information through XML, databases are accessed through XML files, and so on. So how quickly do you you need from an XML file?
As we know, Java JAXP and Microsoft.NET have XML parsers, Microsoft.NET is read-side analysis, and JAXP is read in memory and then analyzed (there is an event mechanism to read), in short, is not conducive to fast reading. Based on this, both Microsoft.NET and JAXP provide an XPath mechanism to quickly navigate to the desired nodes in the XML file.
For example, there is an XML file: Booksort.xml:
<?xml version= "1.0"?>
<!--a fragment of a book store inventory database-->
Using some of the features in XPath, you can also implement simple sorting and simple operations. If data is often summarized in a database, XPath can be used to implement it.
Such as:
Order.xml
<!--represents a customer order-->
<order>
<book isbn= ' 10-861003-324 ' >
<title>the Handmaid ' s tale</title>
<price>19.95</price>
</book>
<CD isbn= ' 2-3631-4 ' >
<title>Americana</title>
<price>16.95</price>
</cd>
</order>
And: books.xml
<?xml version= "1.0"?>
<!--This file represents a fragment of the book store inventory database-->
We can see that 30.97 is the sum of all the price values in the Books.xml, and 36.9 is the sum of all the price values in the Order.xml. Xpah not only can quickly find information, but also can do some basic processing of information.
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.