I want to perform a simple search using xpath, this is my XML

and I want to search the Time nodes and return the Id node value as the result.
this is my code so far, but i dont get any results
XmlNodeList nList = xmlDoc.SelectNodes("//spEvents:Time[. = '" + eventId + "']/parent::node()/spEvents:Times/spEvents:EventTime/spEvents:Time", xmlnsManager);
(Note I am using namespaces)
Thanks
kb
@Jon, my code was working fine with XML to LINQ, as below
return (from feed in xmlDoc_Spektrix.Descendants("Event")
from et in feed.Element("Times").Elements("EventTime")
where Convert.ToDateTime(et.Element("Time").Value).ToShortDateString() == Convert.ToDateTime(dt).ToShortDateString()
select feed.Element("Id").Value).ToList();
but since the namespaces were introduced to the xml feed, my code no longer works, which is why i have had to switch to xpath
this code used to work fine, does anyone know why the above code stops working with namespaces?
The correct response to “introducing namespaces broke my query” isn’t “change technology” it’s “fix the query”. This is really easy with LINQ to XML:
Note the simplified (and more correct in the face of culture changes) conversion of an
XElementtoDateTimeas well.