0

I'm currently exporting XML files from my ERP system and they look like this :

    <?xml version="1.0"?>
    <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>

I have created a list inside sharepoint 2013 for my customers. Is there a way to add the customer value to my list? I had an app that could do this in SP 2007 but the person who created this app isn't here anymore. In the future I would like to be able that when I click on the customer, a document library opens and shows all files related to the customer. Maybe if possible it should add the document automatically to the right customer. Thanks !

4
  • you could create a timerjob that import the xml to a list Commented Apr 25, 2013 at 9:49
  • but i only want the cusomer name from the xml file to be added in my list Commented Apr 25, 2013 at 9:50
  • you could create a custom action that import the file Commented Apr 25, 2013 at 10:45
  • how do I do this? I'm kind of new to SharePoint myself so I don't know much about the functionalities it contains Commented Apr 25, 2013 at 11:03

1 Answer 1

0

I will try this code to implement in some kind of app wish me luck !

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();
                    }
                });
            }
        }
    }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.