Apply Your Knowledge
Exercises
2.1. Compiling XPath Expressions
The .NET Framework developers invested a lot of effort in finding ways to make code more efficient. One performance enhancement in evaluating XPath expressions is the capability to precompile an expression for reuse. This exercise shows you how to use the Compile() method of the XPathNavigator class to create a precompiled XPath expression, represented as an XPathExpression object.
Estimated Time: 15 minutes.
1. | Create a new Visual C# .NET project to use for the exercises in this chapter. |
2. | Add a new XML file to the project. Name the new file Books1.xml. Modify the XML for Books1.xml as follows:
<?xml version="1.0" encoding="UTF-8"?> <Books> <Book Pages="1088"> <Author>Delaney, ... |
Get MCAD/MCSD Training Guide (70-320): Developing XML Web Services and Server Components with Visual C#™ .NET and the Microsoft .NET Framework now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.