zoukankan      html  css  js  c++  java
  • C# 读取XML属性 更新到SharePoint 2013 中

     public void UpdateSharePointListFromXML()
            {
                string filename = Server.MapPath("XMLFile1.xml");
                XmlDocument xmldoc = new XmlDocument();
                xmldoc.Load(filename);
                XmlNodeList topM = xmldoc.DocumentElement.ChildNodes;
                foreach (XmlElement element in topM)
                {
                    if (element.Name == "ISA_Info")
                    {
    
                        Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(delegate()
                        {
                            SPSite site = new SPSite("http://jack-7716f30e37:2012");
                            using (SPWeb web = site.OpenWeb())
                            {
                                web.AllowUnsafeUpdates = true;
                                site.AllowUnsafeUpdates = true;
                                SPList list = web.Lists["MyList"];
                                SPListItem Item = list.Items.Add();
                                Item["field"] = element.Attributes[0].Value.ToString();
                                Item["Value"] = element.Attributes[1].Value.ToString();
                                Item.Update();
                                list.Update();
                            }
                        });
    
                    }
                }
            }
    <?xml version="1.0" encoding="utf-8" ?>
    <ISA xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <ISA_Info field="ISA.FullPath" value="\\nas\apps\test\PDF\AKF000210460100051.pdf"/>
      <ISA_Info field="ISA.Customer" value="Test Customer"/>
      <ISA_Info field="ISA.Type" value="AKF"/>
      <ISA_Info field="Meta.Categorie" value="INS"/>
      <ISA_Info field="Meta.Doc.Date" value="08/06/2010"/>
      <ISA_Info field="Meta.FileNumber" value="021046"/>
      <ISA_Info field="Meta.Year" value="2010"/>
      <ISA_Info field="Meta.Description" value=" Installatie P360 scanner"/>
    </ISA>
  • 相关阅读:
    angular7新特性
    ES6基本语法入门
    uni-app 请求封装
    Node.js- Express框架
    webpack知识分享
    【JS】深入理解JS原型和继承
    JavaScript 变量作用域和声明提升
    在元素上写事件和addEventListent()的区别
    webStrom快捷键快速创建React组件
    vue移动端 实现手机左右滑动入场动画
  • 原文地址:https://www.cnblogs.com/ahghy/p/3044370.html
Copyright © 2011-2022 走看看