我有以下 XML
<location>
<name>Name</name>
<weeks>
<week>
<Sunday>
<times>
<currently_open>false</currently_open>
<status>open</status>
<hours>
<hour>
<from>10am</from>
<to>6pm</to>
</hour>
</hours>
</times>
<date>2018-09-23</date>
<rendered>10am - 6pm</rendered>
</Sunday>
<Monday>
<times>
<currently_open>false</currently_open>
<status>open</status>
<hours>
<hour>
<from>8:30am</from>
<to>12am</to>
</hour>
</hours>
</times>
<date>2018-09-24</date>
<rendered>8:30am - 12am</rendered>
</Monday>
<Tuesday>
<times>
<currently_open>false</currently_open>
<status>open</status>
<hours>
<hour>
<from>8:30am</from>
<to>12am</to>
</hour>
</hours>
</times>
<date>2018-09-25</date>
<rendered>8:30am - 12am</rendered>
</Tuesday>
<Wednesday>
<times>
<currently_open>true</currently_open>
<status>open</status>
<hours>
<hour>
<from>8:30am</from>
<to>12am</to>
</hour>
</hours>
</times>
<date>2018-09-26</date>
<rendered>8:30am - 12am</rendered>
</Wednesday>
<Thursday>
<times>
<currently_open>false</currently_open>
<status>open</status>
<hours>
<hour>
<from>8:30am</from>
<to>12am</to>
</hour>
</hours>
</times>
<date>2018-09-27</date>
<rendered>8:30am - 12am</rendered>
</Thursday>
<Friday>
<times>
<currently_open>false</currently_open>
<status>open</status>
<hours>
<hour>
<from>8:30am</from>
<to>12am</to>
</hour>
</hours>
</times>
<date>2018-09-28</date>
<rendered>8:30am - 12am</rendered>
</Friday>
<Saturday>
<times>
<currently_open>false</currently_open>
<status>open</status>
<hours>
<hour>
<from>10am</from>
<to>6pm</to>
</hour>
</hours>
</times>
<date>2018-09-29</date>
<rendered>10am - 6pm</rendered>
</Saturday>
</week>
</weeks>
</location>
我已经能够使用以下代码获取名称、日期和呈现的值
String URLString = "https://api3.libcal.com/api_hours_grid.php?iid=4246&format=xml&weeks=1&systemTime=0";
XDocument xdoc = new XDocument();
xdoc = XDocument.Load(URLString);
var location = (from p in xdoc.Descendants("location")
from s in p.Descendants("week").Elements()
//from l in p.Descendants().Where( l => l.Ends)
select new
{
CampusName = (string)p.Element("name"),
WeekD = (string)s.Element("date"),
OpenHours = (string)s.Element("rendered"),
//D = p.Descendants("week").Where(z => p.Element.EndsWith("day"))
}).ToList();
我希望能够获取那些包含日期名称的节点的值,例如星期日、星期一等。我已经尝试在我的 from 语句和 select new 语句中使用 .EndsWith ,但都不正确。有人可以指出如何使用它的正确方向吗?
感谢
山姆