To use XPath in LINQ, add a reference to System.Xml.XPath. This will make the System.Xml.XPath.Extensions come into scope. Then, you can use the XPathEvaluate() method.
I’m including it here in case the source site goes away . . .
An XPath expresssion is a series of location steps separated by slashes (/). Each step selects a set of nodes in relation to the current node. These nodes become the current node(s) for the next step. The set of nodes selected by the expression are the nodes remaining after processing each step in order.
For example, the expression child::Part consists of a single step. This step selects the set of all Part elements that are children of the current node. The expression parent::node()/child::Part has two steps. The first step (parent::node()) selects a single node — the parent of the current node. The second step (child::Part) selects all Part elements that are children of that node. Thus, the expression identifies all Part children of the parent of the current node. In other words, it selects all Part siblings of the current node, possibly including the current node.
A step in an XPath expression consists of three parts: an axis, a node test, and zero or more predicates. The axis specifies the direction to move in the document tree (which is roughly the same as the DOM document tree). For example, the child axis says to look at all child nodes. The parent axis says to look at the parent node. The self axis says to look at the current node. The descendant axis says to look at all descendant nodes. And so on.
A node test tests whether nodes encountered along the specified axis should be selected for the next step. For example, in child::Part, child is the axis and Part is the node test. A child node satisfies the node test if it is an element with the name of Part. There are node tests that check the element, attribute, and namespace name, as well as tests that check if the node is a text, comment, or processing instruction node.
A predicate is an expression that filters nodes selected by the node test. It takes the form of an equality (=, !=, >, <, >=, <=) expression. For example, [self::text()="123"] tests if the text of the current node is "123". And [child::PartNumber/self::text()="123"] tests if the current node has a PartNumber child with text of "123". Thus, the XPath expression child::PartNumber[self::text()="123"] selects all PartNumber children of the current node with text "123". And (more informally) child::Part[child::PartNumber/self::text()="123"] selects all parts that are children of the current node and have a part number of "123".
If you want to get Twitter Bootstrap 2.3.2 up and running with ASP.NET MVC4, there is a wonderful set of projects on NuGet for that. However, it’s not straight forward to get it installed. There are issues that have not been resolved due to the author’s time constraints (admittedly by him) in keeping up the NuGet project. Still, if you want to get an MVC4 Bootstrap 2.3.0 app going, this is a pretty good place to start inspite of the problems.
I have struggled to get it up and going and have noticed in my search for answers that others have as well. I have finally converged upon a sequence of steps that get it going. I’ve not found these all in one place, so, I’ve decided to document my approach here. I hope it works for you . . .
- In Visual Studio, create a new, empty MVC 4 application.
- Open the Library Package Manager console window and load the two Twitter Bootstrap MVC 4 and Sample packages
- “Tools | Library Package Manager | Package Manager Console”
- At the PM> prompt, type
install-package twitter.bootstrap.mvc4 -Version 1.0.90
and press [Enter] and wait for it to install.
- At the PM> prompt, type
install-package twitter.bootstrap.mvc4.sample -Version 1.0.90
and press [Enter] and wait for it to install
- Later versions have bugs that have not been fixed. 1.0.90 is a stable version
- Paths in the BootstrapBundleConfig are wrong and need to be fixed. Change it to something like this . . .
- The Bootstrap files need to be updated (the ones that come down in NuGet aren’t right). You’ll need to install it manually in your project.
- Get bootstrap 2.3.2 from here . . . click the big blue “Download Bootstrap” button.
- Open the download file, extract it and copy the css and js files over the existing ones in the \Content and \Scripts folders . . . watch out for the paths
- In the _BootstrapLayout.basic.cshtml, change the lines
<link href=”@Styles.Url(“~/content/css”)” rel=”stylesheet”/>
OR . . .
Here’s a good article on Bootstrap and MVC
Twitter Bootstrap files are freely hosted by this company.