我有以下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,但是都不正确。有人可以指出我正确使用方法的方向吗?
谢谢
山姆
答案 0 :(得分:0)
如果我理解正确,那么您希望获得该事件的存储日期。为此,您只需执行以下操作,
.mjs
这应该为您提供有关相对数据的一天。