I am trying to parse a bit of data from an HTML file, but my Linq statement is not working. Here is the XML/HTML. Below, how can I extract the string "41.8;12.23" from the geo.position meta tag? Thx!!
Here is my Linq
String longLat = (String)
from el in xdoc.Descendants()
where
(string)el.Name.LocalName == "meta"
& el.FirstAttribute.Name == "geo.position"
select (String) el.LastAttribute.Value;
Here is my Xdocument
<span>
<!--CTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="application/xhtml+xml; charset=utf-8" http-equiv="Content-Type" />
<meta content="text/css" http-equiv="Content-Style-Type" />
<meta name="geo.position" content="41.8;12.23" />
<meta name="geo.placename" content="RomeFiumicino, Italy" />
<title>RomeFiumicino, Italy</title>
</head>
<body />
</html>
</span>
Edit: My query as given returns nothing. The "inner" query seems to return a list of all the meta elements instead of just the one element I want.
Edit: The following Linq query works against the same XDocument to retreive a table with class name = "data"
var dataTable =
from el in xdoc.Descendants()
where (string)el.Attribute("class") == "data"
select el;