Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

Get data from Sharepoint List (XML?) to ListView

$
0
0

So, I dont have any experience with XML's and I dont know how to get the information out of them in a form that I am able to have populate a ListView. 

 

So far I have been using this script: http://www.autoitscript.com/forum/topic/162883-xml-sharepoint-caml-query-not-filtering-based-on-query/

 

In an attempt to pull the information, which it does, into an XML format for variable $x

 

 

How can I extract the information from $x and use it to poupulate a ListView.

 

Heres what the script looks like with my information put in for the site:

AutoIt         
#include-once Global $BasicAuthentication = _Base64Encode("")     ;------------------------------------------------------------------------     ;Example:     ; dim $x     ; $x=_sp_getxml("http://<yoursite>/<your subsite>","<yourlist","")     ; _SP_DeleteListItems("http://<yoursite>/<your subsite>","<yourlist>",$x)     ;------------------------------------------------------------------------ Dim $x $x=_sp_getxml("http://coin/sites/west/CentralDivision/WIFulfillCenter","WFX Tech Time Off Pending",'<Query><OrderBy><FieldRef Name="ows_Modified" Ascending="TRUE"></FieldRef></OrderBy><Where><And><BeginsWith><FieldRef Name="ows_Status"></FieldRef><Value Type="Text">Closure</Value></BeginsWith><IsNotNull><FieldRef Name="Title"></FieldRef></IsNotNull></And></Where></Query>') ;ConsoleWrite($x) MsgBox(1, "ScrapTest4.au3", $x) Func _SP_GetXML($url,$list,$CAML)     ;------------------------------------------------------------------------     ;Make sure your default view is "AllItems"     ; $url= URL to your site/subsite     ; $list= Name of the Sharepointlist to query     ; $CAMLquery= CAML based query string. Leave empty for the whole list.     ;Return: XML string from Sharepoint list containing the filtered items     ;------------------------------------------------------------------------     Dim $request     $url = $url & "/_vti_bin/Lists.asmx"     $request =  "<?xml version='1.0' encoding='utf-8'?>"     $request =  $request & "<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>"     $request =  $request & "<soap:Body>"     $request =  $request & "<GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'>"     $request =  $request & "              <listName>" & $list & "</listName>"     $request =  $request & "              <ViewName></ViewName>"     $request =  $request & '              ' & $CAML     $request =  $request & "              <ViewFields></ViewFields>"     $request =  $request & "              <rowLimit>20</rowLimit>"     ;$request =  $request & "             <queryOptions></queryOptions>"     $request =  $request & "              <webID></webID>"     $request =  $request & "</GetListItems>"     $request =  $request & "</soap:Body>"     $request =  $request & "</soap:Envelope>"     ;post it up and look at the response     $XmlHttp=ObjCreate("Microsoft.XMLHTTP")     $XmlHttp.open ("Get", $url, False)     ;Pass username:password as a base64 string ($BasicAuthentication)     $XmlHttp.SetRequestHeader ("Authorization", "Basic " & $BasicAuthentication)     $XmlHttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8")     $XmlHttp.SetRequestHeader ("Accept", "text/xml; charset=UTF-8")     $XmlHttp.send ($request)     return ($XmlHttp.responsetext) EndFunc Func _Base64Encode($Data, $LineBreak = 76)     Local $Opcode = "0x5589E5FF7514535657E8410000004142434445464748494A4B4C4D4E4F505152535455565758595A6162636465666768696A6B6C6D6E6F707172737475767778797A303132333435363738392B2F005A8B5D088B7D108B4D0CE98F0000000FB633C1EE0201D68A06880731C083F901760C0FB6430125F0000000C1E8040FB63383E603C1E60409C601D68A0688470183F90176210FB6430225C0000000C1E8060FB6730183E60FC1E60209C601D68A06884702EB04C647023D83F90276100FB6730283E63F01D68A06884703EB04C647033D8D5B038D7F0483E903836DFC04750C8B45148945FC66B80D0A66AB85C90F8F69FFFFFFC607005F5E5BC9C21000"     Local $CodeBuffer = DllStructCreate("byte[" & BinaryLen($Opcode) & "]")     DllStructSetData($CodeBuffer, 1, $Opcode)     $Data = Binary($Data)     Local $Input = DllStructCreate("byte[" & BinaryLen($Data) & "]")     DllStructSetData($Input, 1, $Data)     $LineBreak = Floor($LineBreak / 4) * 4     Local $OputputSize = Ceiling(BinaryLen($Data) * 4 / 3)     $OputputSize = $OputputSize + Ceiling($OputputSize / $LineBreak) * 2 + 4     Local $Ouput = DllStructCreate("char[" & $OputputSize & "]")     DllCall("user32.dll", "none", "CallWindowProc", "ptr", DllStructGetPtr($CodeBuffer), _                                                     "ptr", DllStructGetPtr($Input), _                                                     "int", BinaryLen($Data), _                                                     "ptr", DllStructGetPtr($Ouput), _                                                     "uint", $LineBreak)     Return DllStructGetData($Ouput, 1) EndFunc

And my output:

<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><GetListItemsResponse xmlns="http://schemas.microsoft.com/sharepoint/soap/"><GetListItemsResult><listitems xmlns:s='uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882'      xmlns:dt='uuid:C2F41010-65B3-11d1-A29F-00AA00C14882'      xmlns:rs='urn:schemas-microsoft-com:rowset'      xmlns:z='#RowsetSchema'> <rs:data ItemCount="9">    <z:row ows_Sup_x0020_Name='Tad Peak' ows_Tech_x0020_ID_x0020_Number='0267' ows_LinkTitle='Zach Washa' ows_Start_x0020_Date='2015-05-15 08:00:00' ows_End_x0020_Date='2015-05-15 12:00:00' ows_Tech_x0020_Time_x0020_Off_x0020_='Vacation' ows_NOTES='Kindergarten graduation for Corinne' ows_Author='19945;#Washa, Zach P' ows_Created='2015-03-28 14:42:17' ows_days='float;#47.7206365740785' ows__ModerationStatus='0' ows__Level='1' ows_UniqueId='70898;#{7610386C-0B9D-49B4-870B-0CE3C89D8A9E}' ows_FSObjType='70898;#0' ows_Created_x0020_Date='70898;#2015-03-28 14:42:17' ows_Modified='2015-03-28 14:42:17' ows_MetaInfo='70898;#' ows_ID='70898' ows_owshiddenversion='1' ows_Title='Zach Washa' ows_FileLeafRef='70898;#70898_.000' ows_PermMask='0x1b03c4312ef' ows_FileRef='70898;#sites/west/CentralDivision/WIFulfillCenter/Lists/WFX Tech Time Off Form/70898_.000' />    <z:row ows_Entered_x0020_In_x0020_WFX='No' ows_Sup_x0020_Name='Eric Grose' ows_Tech_x0020_ID_x0020_Number='114' ows_LinkTitle='Marissa Cozza' ows_Start_x0020_Date='2015-04-01 10:00:00' ows_End_x0020_Date='2015-04-01 14:00:00' ows_Type_x0020_of_x0020_Exception='Special Project' ows_NOTES='<div>Truck in for maint</div>' ows_Author='27401;#Grose, Eric' ows_Created='2015-03-28 12:40:10' ows_Same_x0020_Day_x0020_Request_x00='Yes' ows_Is_x0020_This_x0020_A_x0020_CB_x='No' ows_Is_x0020_this_x0020_a_x0020_Syst='No' ows_days='float;#3.88877314814454' ows__ModerationStatus='0' ows__Level='1' ows_UniqueId='70887;#{7D2ADDC2-546E-471C-ADD5-9875F04B7311}' ows_FSObjType='70887;#0' ows_Created_x0020_Date='70887;#2015-03-28 12:40:10' ows_Modified='2015-03-28 12:40:10' ows_MetaInfo='70887;#' ows_ID='70887' ows_owshiddenversion='1' ows_Title='Marissa Cozza' ows_FileLeafRef='70887;#70887_.000' ows_PermMask='0x1b03c4312ef' ows_FileRef='70887;#sites/west/CentralDivision/WIFulfillCenter/Lists/WFX Tech Time Off Form/70887_.000' />    <z:row ows_Entered_x0020_In_x0020_WFX='No' ows_Sup_x0020_Name='Josh Eichelt' ows_Tech_x0020_ID_x0020_Number='0161' ows_LinkTitle='Matt Rapraeger' ows_Start_x0020_Date='2015-04-01 08:00:00' ows_End_x0020_Date='2015-04-01 09:30:00' ows_Type_x0020_of_x0020_Exception='Meeting' ows_NOTES='<div>Reconcile and meeting as matt will be out Mon and Tue for a funeral</div>' ows_Author='671;#Eichelt, Joshua A' ows_Created='2015-03-27 20:16:35' ows_Same_x0020_Day_x0020_Request_x00='No' ows_Is_x0020_This_x0020_A_x0020_CB_x='No' ows_Is_x0020_this_x0020_a_x0020_Syst='No' ows_days='float;#4.48848379629635' ows__ModerationStatus='0' ows__Level='1' ows_UniqueId='70830;#{8D86AF87-B770-41D9-9CDA-BDC0F0DB743A}' ows_FSObjType='70830;#0' ows_Created_x0020_Date='70830;#2015-03-27 20:16:35' ows_Modified='2015-03-27 20:16:35' ows_MetaInfo='70830;#' ows_ID='70830' ows_owshiddenversion='1' ows_Title='Matt Rapraeger' ows_FileLeafRef='70830;#70830_.000' ows_PermMask='0x1b03c4312ef' ows_FileRef='70830;#sites/west/CentralDivision/WIFulfillCenter/Lists/WFX Tech Time Off Form/70830_.000' />    <z:row ows_Sup_x0020_Name='Alan Zarecki' ows_Tech_x0020_ID_x0020_Number='0358' ows_LinkTitle='Brandon Lindgren' ows_Start_x0020_Date='2015-04-10 10:00:00' ows_End_x0020_Date='2015-04-10 21:00:00' ows_Tech_x0020_Time_x0020_Off_x0020_='Vacation' ows_NOTES='Family Birthday Celebration' ows_Author='26841;#Lindgren, Brandon P' ows_Created='2015-03-27 20:07:55' ows_days='float;#13.5778356481460' ows__ModerationStatus='0' ows__Level='1' ows_UniqueId='70828;#{ACB69DE2-1F40-4A7D-B45E-094D79A5788B}' ows_FSObjType='70828;#0' ows_Created_x0020_Date='70828;#2015-03-27 20:07:55' ows_Modified='2015-03-27 20:07:55' ows_MetaInfo='70828;#' ows_ID='70828' ows_owshiddenversion='1' ows_Title='Brandon Lindgren' ows_FileLeafRef='70828;#70828_.000' ows_PermMask='0x1b03c4312ef' ows_FileRef='70828;#sites/west/CentralDivision/WIFulfillCenter/Lists/WFX Tech Time Off Form/70828_.000' />    <z:row ows_Entered_x0020_In_x0020_WFX='No' ows_Sup_x0020_Name='John Hicks' ows_Tech_x0020_ID_x0020_Number='239' ows_LinkTitle='Alex Sulkowski' ows_Start_x0020_Date='2015-03-30 18:00:00' ows_End_x0020_Date='2015-03-30 19:00:00' ows_Type_x0020_of_x0020_Exception='Meeting' ows_NOTES='<div>Review</div>' ows_Author='747;#Hicks, John' ows_Created='2015-03-27 20:06:33' ows_Same_x0020_Day_x0020_Request_x00='No' ows_Is_x0020_This_x0020_A_x0020_CB_x='No' ows_Is_x0020_this_x0020_a_x0020_Syst='No' ows_days='float;#2.91211805555213' ows__ModerationStatus='0' ows__Level='1' ows_UniqueId='70827;#{24222BE3-C5EE-419F-BB0E-5BB30C8A4C5B}' ows_FSObjType='70827;#0' ows_Created_x0020_Date='70827;#2015-03-27 20:06:33' ows_Modified='2015-03-27 20:06:33' ows_MetaInfo='70827;#' ows_ID='70827' ows_owshiddenversion='1' ows_Title='Alex Sulkowski' ows_FileLeafRef='70827;#70827_.000' ows_PermMask='0x1b03c4312ef' ows_FileRef='70827;#sites/west/CentralDivision/WIFulfillCenter/Lists/WFX Tech Time Off Form/70827_.000' />    <z:row ows_Entered_x0020_In_x0020_WFX='No' ows_Sup_x0020_Name='Christopher Gribble' ows_Tech_x0020_ID_x0020_Number='474' ows_LinkTitle='Zac CAves' ows_Start_x0020_Date='2015-03-31 08:00:00' ows_End_x0020_Date='2015-03-31 09:00:00' ows_Type_x0020_of_x0020_Exception='Meeting' ows_NOTES='<div></div>' ows_Author='3079;#Gribble, Christopher R' ows_Created='2015-03-27 19:25:01' ows_Same_x0020_Day_x0020_Request_x00='No' ows_Is_x0020_This_x0020_A_x0020_CB_x='No' ows_Is_x0020_this_x0020_a_x0020_Syst='No' ows_days='float;#3.52429398148524' ows__ModerationStatus='0' ows__Level='1' ows_UniqueId='70825;#{F60BF74A-739F-450B-B1F3-990BB1EFD5FA}' ows_FSObjType='70825;#0' ows_Created_x0020_Date='70825;#2015-03-27 19:25:01' ows_Modified='2015-03-27 19:25:01' ows_MetaInfo='70825;#' ows_ID='70825' ows_owshiddenversion='1' ows_Title='Zac CAves' ows_FileLeafRef='70825;#70825_.000' ows_PermMask='0x1b03c4312ef' ows_FileRef='70825;#sites/west/CentralDivision/WIFulfillCenter/Lists/WFX Tech Time Off Form/70825_.000' />    <z:row ows_Sup_x0020_Name='Jim Banta' ows_Tech_x0020_ID_x0020_Number='0118' ows_LinkTitle='John Gessner' ows_Start_x0020_Date='2015-07-12 08:00:00' ows_End_x0020_Date='2015-07-12 19:00:00' ows_Tech_x0020_Time_x0020_Off_x0020_='Floating Holiday' ows_Author='35724;#Gessner, John' ows_Created='2015-03-27 09:15:51' ows_days='float;#106.947326388894' ows__ModerationStatus='0' ows__Level='1' ows_UniqueId='70765;#{E3EA6319-E1D4-4581-A7C3-778B60B0A3F1}' ows_FSObjType='70765;#0' ows_Created_x0020_Date='70765;#2015-03-27 09:15:51' ows_Modified='2015-03-27 09:15:51' ows_MetaInfo='70765;#' ows_ID='70765' ows_owshiddenversion='1' ows_Title='John Gessner' ows_FileLeafRef='70765;#70765_.000' ows_PermMask='0x1b03c4312ef' ows_FileRef='70765;#sites/west/CentralDivision/WIFulfillCenter/Lists/WFX Tech Time Off Form/70765_.000' />    <z:row ows_Sup_x0020_Name='Doug Kurschner' ows_Tech_x0020_ID_x0020_Number='6514' ows_LinkTitle='Eric Hagman' ows_Start_x0020_Date='2015-05-17 08:00:00' ows_End_x0020_Date='2015-05-24 19:00:00' ows_Tech_x0020_Time_x0020_Off_x0020_='Vacation' ows_NOTES='<div></div>' ows_Author='3141;#Hagman, Eric C' ows_Created='2015-03-26 20:04:58' ows_days='float;#51.4965509259273' ows__ModerationStatus='0' ows__Level='1' ows_UniqueId='70696;#{D89C9455-9BA7-4937-A7C5-87AB9EDF41F0}' ows_FSObjType='70696;#0' ows_Created_x0020_Date='70696;#2015-03-26 20:04:58' ows_Modified='2015-03-26 20:04:58' ows_MetaInfo='70696;#' ows_ID='70696' ows_owshiddenversion='1' ows_Title='Eric Hagman' ows_FileLeafRef='70696;#70696_.000' ows_PermMask='0x1b03c4312ef' ows_FileRef='70696;#sites/west/CentralDivision/WIFulfillCenter/Lists/WFX Tech Time Off Form/70696_.000' />    <z:row ows_Sup_x0020_Name='Doug Kurschner' ows_Tech_x0020_ID_x0020_Number='6514' ows_LinkTitle='Eric Hagman' ows_Start_x0020_Date='2015-04-06 13:00:00' ows_End_x0020_Date='2015-04-06 17:00:00' ows_Tech_x0020_Time_x0020_Off_x0020_='Vacation' ows_NOTES='<div></div>' ows_Author='3141;#Hagman, Eric C' ows_Created='2015-03-26 19:58:34' ows_days='float;#10.7093287036987' ows__ModerationStatus='0' ows__Level='1' ows_UniqueId='70695;#{DA4A402B-16AD-4965-96DE-4563E442AA76}' ows_FSObjType='70695;#0' ows_Created_x0020_Date='70695;#2015-03-26 19:58:34' ows_Modified='2015-03-26 19:58:34' ows_MetaInfo='70695;#' ows_ID='70695' ows_owshiddenversion='1' ows_Title='Eric Hagman' ows_FileLeafRef='70695;#70695_.000' ows_PermMask='0x1b03c4312ef' ows_FileRef='70695;#sites/west/CentralDivision/WIFulfillCenter/Lists/WFX Tech Time Off Form/70695_.000' /> </rs:data> </listitems></GetListItemsResult></GetListItemsResponse></soap:Body></soap:Envelope>

The information I need IS there! but the easiest way I was able to figure out was to safe $x to a file, Re-open the file and filter out the information a piece at a time as the file is read.

 

Any Ideas would help!


Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>