• XML To Linq 读取Sharepoint列表中的附件列信息


    通过页面查看,列表附件信息列的内容如下:

    var x = @"<div class='ExternalClass9936DCD1F074427B891D09CFCEFC2AB6'><p><a href='/sites/twf/wml/费用明细1123.doc'>"                     +"<img class='ms-asset-icon ms-rtePosition-4' alt='费用明细1123.doc' src='/sites/twf/_layouts/images/icdoc.png' />费用明细1123.doc</a></p>"                    

    +"<p><a href='/sites/twf/wml/费用明细1123-2.doc'><img class='ms-asset-icon ms-rtePosition-4' alt='费用明细1123-2.doc' src='/sites/twf/_layouts/images/icdoc.png' />费用明细1123-2.doc</a></p><p> </p></div>";      

    使用Linq To XML解析数据,如下:      

    var element = XElement.Parse(x);            

    var links = element.Descendants("a");//获取所有a链接          

    foreach (var link in links)            

    {                

      var fileName = link.Value;//获取文件名             

      var fileUrl = link.Attribute("href").Value;//获取链接地址                

      Console.WriteLine("{0} :{1}", fileName, fileUrl);                

      Console.WriteLine(result);            

    }

  • 相关阅读:
    *Reverse Linked List II
    *Insertion Sort List
    Convert Sorted List to Binary Search Tree
    Reverse Integer
    read cache return null
    纳秒和随机数
    libthread_db
    gdb
    tls session resumption
    http://www.linux-commands-examples.com/xmllint
  • 原文地址:https://www.cnblogs.com/thankyou555/p/3439741.html
Copyright © 2020-2023  润新知