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>
  • 相关阅读:
    写简单游戏,学编程语言-python篇
    RSS阅读器python实现概述
    python简易爬虫来实现自动图片下载
    SQL SERVER 2008 R2 SP3 发布
    动态规划问题总结 (转载)
    typedef with const 联合的说明
    C++ 初始化列表
    C++de构造函数
    排序算法温习
    java中读取properties配置文件用例
  • 原文地址:https://www.cnblogs.com/ahghy/p/3044370.html
Copyright © 2011-2022 走看看