开发者

create xml from sharepoint query?

I am querying a sharepoint list like

<where><Field Ref Name='Title'/><Value type='Text'>A</value></where>

now I am creating a webpart where I want to create xml based on this query.I don't know how to achieve this mainly I want sth开发者_Go百科 like content query webpart like getting xml from querying a list and then apply xsl on it. Can anyone tell me how it can be possible??

Thanks,


Do you want to have the result set as XML? Then you should read these:

  • explains different ways you can read XML from sharepoint http://blogs.msdn.com/kaevans/archive/2009/05/01/getting-xml-data-from-a-sharepoint-list-the-easy-way.aspx
  • Lists.asmx web service explanation with examples http://msdn.microsoft.com/en-us/library/lists.lists.getlistitems.aspx
  • SPWeb has GetSiteData method that returns DataTable. This can be easily translated into XML http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spweb.getsitedata.aspx

EDIT: to turn your DataTable into XML, you can add it to a DataSet and then call GetXml, something like this:

    Dim o As New DataTable("testTable")
    o.Columns.Add("TestCol")
    o.Rows.Add(New Object() {"Testvalue1"})
    o.Rows.Add(New Object() {"Testvalue2"})

    Dim oSet As New DataSet()
    oSet.Tables.Add(o)

    MessageBox.Show(oSet.GetXml) 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜