我对xml解析相当陌生。c#XDocument问题
继非常基本教程我尝试解析由CalDav的服务器返回以下XML:
<?xml version="1.0" encoding="utf-8" ?>
<multistatus xmlns="DAV:">
<response>
<href>/caldav.php/icalendar.ics</href>
<propstat>
<prop>
<getetag>"xxxx-xxxx-xxxx"</getetag>
</prop>
<status>HTTP/1.1 200 OK</status>
</propstat>
</response>
<sync-token>data:,20</sync-token>
</multistatus>
现在我想找到我的“响应”子孙如下:
Doc = XDocument.Parse(response);
foreach (var node in xDoc.Root.Descendants("response")) {
// process node
}
没有后代被发现。我在这里错过了什么吗?我的根的确是一个“多状态”元素,它说,它具有的元素,但它似乎并没有因为他们可以通过名字找到...
任何帮助,将不胜感激!
LINQ到XML是非常强大的,简单易学,这将是值得的退后一步,也更多地了解XPath和甚至XSLT - 如果只更多地欣赏linq-to-xml。 – NicoE