0

次の XDocument があります。

<?xml version="1.0" encoding="utf-8"?>
   <D:multistatus xmlns:D="DAV:" xmlns:Office="urn:schemas-microsoft-com:office:office"    xmlns:Repl="http://schemas.microsoft.com/repl/" xmlns:Z="urn:schemas-microsoft-com:">
   <D:response>
       <D:href>http://aaa</D:href>
       <D:propstat>
           <D:prop>
               <D:displayname>a</D:displayname>
               <D:isFolder>t</D:isFolder>
           </D:prop>
           <D:status>HTTP/1.1 200 OK</D:status>
      </D:propstat>
  </D:response>
  <D:response>
        .
        .
  </D:response>  

すべての応答を取得するにはどうすればよいですか? (「D:response」タグの下のすべて、そして明らかに「D:propstat」および「D:prop」タグの下のすべて - D:href、D:displayname、D:isFolder を取得したい)

私はこれをやっています:

XNamespace d = "DAV:";
foreach (var file in doc.Descendants(d + "response"))
{
    if ((string)file.Element(d + "href") != (string)Configuration.Configs["baseUrl"])
    {
        string ref = (string)file.Element(d + "href");
        foreach (var propstat in file.Descendants(d + "propstat"))
            foreach (var prop in propstat.Descendants(d + "prop"))
            {
                string name = (string)prop.Element(d + "displayname");
                if (prop.Element(d + "isFolder") != null && (string)prop.Element(d + "isFolder") == "t")
                    string type = "folder";
                else
                    string type = "file";
            }
    }
} 

より良い方法はありますか?

4

4 に答える 4