Link to home
Start Free TrialLog in
Avatar of llessurt
llessurt

asked on

Export SharePoint Data as XML

I need help creating a script to pull specific data from a MS SharePoint list when requested via HTTP (Msxml2.ServerXMLHTTP).

I do not think I can use owssvr.dll directly, because the list contains sensitive information that I do NOT want to be accessible.  I would also like to add XML information such as the date of the request.

A web server will request the XML data from a remote server running SharePoint.  The web server will then filter and sort the XML records.

I have MS FrontPage 2003, if that makes it easier.

Thank you for your advice!
Avatar of rdcpro
rdcpro
Flag of United States of America image

You have number of possibilities, with SharePoint.  Since the current version of SharePoint doesn't do any security trimming (though SharePoint 2007 does), your best bet is to use the SharePoint web service for this.  I'm at home at the moment, but when I get to work, I'll post more info.

I use SharePoint web services quite a bit--they're very handy, and pretty easy to use.  You could use the Search service, which allows you to select the data from the list that you want, but there is a list service as well.  If I recall correctly, you can do almost anything you want via the web service, except create a new list...

In any case, I'll post an example when I get to work in a few hours.  Do you also have Visual Studio 2003, and is the client server (the one you're say you're going to use MSXML with) running ASP.NET?

Regards,
Mike Sharp
Avatar of llessurt
llessurt

ASKER

Please illustrate how to implement the SharePoint web service.

The client server is running ASP.NET -- I'm planning to save the XML response as a file so it can be accessed directly from the client.  The advice a need is how to compile the XML from the SharePoint list to send to the client.

I do not have Visual Studio.

Thank You
Is there a better category to make this post?
ASKER CERTIFIED SOLUTION
Avatar of rdcpro
rdcpro
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks rdcpro, I'm still looking at your solution -- this process may not be as straightforward as I was hoping.  I am lacking in experience I guess.

FrontPage gives me a data connection very easily, but wants to format it in a table with with menus and so many on a page, etc.

Basically I want to open a SharePoint list, specify a query and the fields I want, add a the current date, and send the whole thing to the remote web server as an XML document.  The web server will save the document and access the saved version locally.

It will be accessible remotely, so it is important that only the specified fields with the query can be accessed (exported).

Am I going about this the wrong way?  With these methods, it looks like I will have to manually build the XML document (and I haven't been successful).
I wish I was more experienced with FrontPage.  No, wait, I take that back.  ;^)

Actually, it may not be possible at all, if FrontPage doesn't allow you to write any code.  But the DataSet doesn't have to be bound to a datagrid for display, and you should be able to get the XML directly from the DataSet.

Otherwise, you'll have to use the Web Service directly, and construct the web client yourself, assuming you can do this in FrontPage.  

You can always do this in code and compile from the command line, too.  Visual Studio is nice, but it's a luxury, not a requirement.  But I'd say development in Notepad and command line compilation is not for the faint of heart!

Regards,
Mike Sharp
I appreciate all your help.  I would repost, but I'm not sure where this question should go.  I downloaded Visual Studio Express 2005, but I have no idea what to do with it.

I'm looking for something very simple....  I know this is a mess, but it illustrates what I am looking for.

<%@ Page Language="VB" %>
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls"
      Assembly="Microsoft.SharePoint, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities"
      Assembly="Microsoft.SharePoint, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Import Namespace="Microsoft.Sharepoint" %>

<script runat="server">

    Public Class SPWeb
        Inherits System.Object
    End Class
   
    Sub Page_Load()

        Dim mySite As SPWeb = SPControl.GetContextWeb(Context)
        Dim list As SPList = mySite.Lists("ATS Job Orders")

        Dim query As New SPQuery()
            query.Query = "<Where><Eq><FieldRef Name="Status"/><Value Type="x:string">In Print</Value></Eq></Where><OrderBy><OrderField Name="Created" Type="xsd:string" Direction="DESC"/><OrderField Name="Order_x0020__x0023_" Type="xsd:string" Direction="DESC"/></OrderBy>"

        Dim myItems As SPListItemCollection = list.GetItems(query)
        Dim item As SPListItem
        Response.Write("<xml><books>")
        For Each item In myItems
            Response.Write("<book ID" & CHR(34) item("id").ToString() & CHR(34) & "><title>" & item("Title").ToString() & "</title></book>")
        Next item
       
        Dim list As SPList = mySite.Lists("Staff")
        Dim query As New SPQuery()
query.Query = "<Where><Eq><FieldRef Name="Status"/><Value Type="x:string">Open</Value></Eq></Where><OrderBy><OrderField Name="Created" Type="xsd:string" Direction="DESC"/><OrderField Name="Order_x0020__x0023_" Type="xsd:string" Direction="DESC"/></OrderBy>"

        Dim myItems As SPListItemCollection = list.GetItems(query)
        Dim item As SPListItem
        Response.Write("</books><authors>")
         For Each item In myItems
            Response.Write("<name>" & item("Name").ToString() & "</name>")
        Next item
        Response.Write("</authors></xml">)
    End Sub
</script>


This ASP page retreives the data:

<%
Option Explicit
On Error Resume Next
Response.Buffer = True

Dim xml, fso, xmldom, objNodeList

Set xml = Server.CreateObject("Msxml2.ServerXMLHTTP")
xml.Open "POST", "https://www.remoteserver.com/customexport.aspx", False
xml.Send

      Set fso = Server.CreateObject("scripting.FileSystemObject")
      Set datafile = fso.CreateTextFile("c:\booksauthors.xml", true)
      datafile.write xml.responseText
      Set datafile = Nothing
      Set fso = Nothing

Set xml = Nothing

response.redirect newpage
%>
I never did get SharePoint WebService to do what I wanted it to do.  I ended up using a table generated by MS-FrontPage (very easy to create with a few clicks), requesting it via HTTP (Msxml2.ServerXMLHTTP, and manipulating it as text to pull out the data and create an XML file.

I very much appreciate your help and suggestions.

Thank You!