有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java返回SharePoint列表列标题的列表

在Java中,我与Sharepoint working有一个连接,当我明确指定数据列的内部名称时,它可以检索列表中的数据,如下图所示。 ArrayList listHash=新建ArrayList(); 字符串viewName=“”; GetListItems。ViewFields ViewFields=null; GetListItems。Query msQuery=null; GetListItems。QueryOptions QueryOptions=null; 字符串webID=“”; 字符串rowLimit=“”

GetListItemsResponse.GetListItemsResult result = listsoap.getListItems(listName, "", msQuery, viewFields, "150", queryOptions, webID);
Object listResult = result.getContent().get(0);

Element element = (Element)result.getContent().get(0);
NodeList nl = element.getElementsByTagName("z:row");
System.out.println("\n=> " + nl.getLength() + " results from SharePoint Online\n");
for(Integer i = 0; i < nl.getLength(); i++) {

     NamedNodeMap attributes = nl.item(i).getAttributes();

     //Add each field item to the arraylist
     String columnName1 = "ows_ClientName";
     String columnName2 = "ows_Address";
     System.out.println(attributes.getNamedItem(columnName1).getNodeValue());
     System.out.println(attributes.getNamedItem(columnName2).getNodeValue());
}

但我想从sharepoint列表中自动检索这些列名,这样我就可以更一般地阅读它,而不必在阅读之前明确知道列表中列的内部名称。这能实现吗

感谢您的帮助

关于


共 (1) 个答案

  1. # 1 楼答案

    我假设您正在使用SharePoint Web服务。如果是这种情况,您可以尝试调用GetList方法,并将listname作为参数传递给该方法。web服务的结果将是列表的模式,其中包含列表的详细信息,包括列的内部名称。让我知道这是否有效