我有一个类型的字符串string xml = @"<recurrence><rule><firstDayOfWeek>mo</firstDayOfWeek><repeat><daily dayFrequency=""1"" /></repeat><windowEnd>2012-10-31T10:00:00Z</windowEnd></rule></recurrence>";
我想读取这里的dayFrequency
值1
,有没有办法可以直接dayFrequency
在标签下读取daily
,同样有很多这样的标签,例如a="1"、b="King"等,所以我想直接读取值分配给一个变量。
请帮忙。
我使用的以下代码读取重复标签
string xml = @"<recurrence><rule><firstDayOfWeek>mo</firstDayOfWeek><repeat><daily dayFrequency=""1"" /></repeat><windowEnd>2012-10-31T10:00:00Z</windowEnd></rule></recurrence>";
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(xml);
// this would select all title elements
XmlNodeList titles = xmlDoc.GetElementsByTagName("repeat");