Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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 !

share|improve this question
    
you could create a timerjob that import the xml to a list –  Remko Apr 25 '13 at 9:49
    
but i only want the cusomer name from the xml file to be added in my list –  Vandoorn Kevin Apr 25 '13 at 9:50
    
you could create a custom action that import the file –  Remko Apr 25 '13 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 –  Vandoorn Kevin Apr 25 '13 at 11:03
add comment

1 Answer 1

up vote 0 down vote accepted

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();
                    }
                });
            }
        }
    }
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.