score:3
You look for "td"
elements but at the top level of the node you only find a "tr"
element. That's why you don't get any elements. Try this:
from c in info.Elements("tr").Elements("td")
Also, you should check if there are any elements in the sequence before calling First()
(or use FirstOrDefault()
which returns null if there is no element).
If you don't know the path and only want all "td"
elements with that tag value, you can also use the Descendants
extension method:
from c in info.Descendants("td")
score:0
Elements
would give you the immediate child elements of the root in this case info. You need to drill down to the elements you are looking for and then extract them by the Where
clause. In your case the immediate children are the <tr>
s.
Source: stackoverflow.com
Related Query
- get Node by it's attribute in linq to xml
- loop through specific attribute using xml linq and c# and get its lowest value
- Get attribute value of parent node by Linq to XML
- Linq to XML selecting a node bases on a attribute value
- Get max attribute value from XML using LINQ
- Parsing a xml string & retrieving its attribute Value using Linq to XML C#
- LINQ to XML C# get root element attribute
- How Update a node attribute in xml using Linq query?
- get xml node value from id attribute c#
- Get specific node from Xml usin Linq
- LINQ to XML - filter XElement based on its node value compared to another XElement?
- get xml attribute using linq
- Search and get all child nodes of XML node base on attribute id
- Linq to XML Get parent element attribute value by querying it's children
- Linq XML query - How do I return a node that meets a condition within its own nested nodes?
- Get node value xml with LINQ c#
- How to get an XML attribute value with Linq to XML?
- LINQ to XML query. Get element attribute
- LINQ to XML Select Nodes based on child node and attribute
- C#: LINQ to XML Show particular Node attribute values from XML file
- How to get XML Attribute and Element with One Linq Query?
- Get Attribute Values using LINQ to XML with Unknown Elements
- Get last attribute value in XML using Linq
- Linq to XML get nested child attribute based on parent attribute
- Linq To XML: Find XElement by name in XML and get parent attribute
- LINQ request for getting the furthest xml child node with an attribute
- Get node attribute xml C#
- linq to xml - get childrem of those nodes with a certain attribute
- Get XML tag attribute value from parent node to last child node
- get attribute value from xsd node using LINQ
More Query from same tag
- Linq query, how to check for a null value and use the value 0 in place of a null?
- T-Sql to linq conversion issues (order by)
- Linq Expression tree compiling non-trivial object constants and somehow referring to them
- Get substring of field using EF and SQL Server
- LINQ Query - Explanation needed of why these examples are different
- How to remove (via linq) duplicates from a List of objects
- Linq Concat to Lazy-Load it's contents
- ICollection properties Sorting in ASP.Core using LINQ
- C# Linq with Groupby like items
- When searching for an item in a generic list should I use LINQ or Contains?
- writing a linq query like statement in javascript
- LINQ query is slow
- Convert SQL to Entity Framework Linq convert to list C#
- Non-recognized member in lambda expression of EF Core ThenInclude in Extension method
- Convert dictionary values to list using linq
- Adding new element to dictionary in Linq
- How to create a left join instead of inner join?
- Using methods in Linq expressions
- Linq to objects Joining collections and filtering
- LINQ Enumerable Threading
- How could I use Func<> to modify a single condition of a lambda
- Selecting array values from specific indexes order by index array
- Cannot iterate through two different collections simultaneously c#
- Linq Query return a Concat of Dates to String?
- LINQ to Entities does not recognize ToString using query syntax
- table adapter returning incorrect results
- C#: Recursively get Dictonary value with deep string expression
- "Non white space characters cannot be added to content" when creating Linq XML document
- Finding Average using nested queries on another table
- Retrieve all the items from a table where the text of a table column is contained in a list of items (ASP.NET Core 2.2 C# LINQ)