Access SharePoint list in Flex

Simply put together the link as below.

http://[Server]/_vti_bin/owssvr.dll?Cmd=Display&List={GUID}&XMLDATA=TRUE

How to get GUID for List  

1. Site Actions -> Site Settings

2. Click on Site Libraries and lists

3.click on the list which you would like to access as XML.

4. Get the List ID from the Redirected URL

5.http://[Server]/_vti_bin/owssvr.dll?Cmd=Display&List={80D18622-447F-4900-90A5-E424EDB95DCD}&XMLDATA=TRUE

6. XML Output

How to read SharePoint List from Flex 

<?xml version=”1.0″ encoding=”utf-8″?><mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml” layout=”absolute”
creationComplete=”onCreate(event)”><mx:Script><![CDATA[
import mx.controls.Alert;
private function onCreate(e:Event):void
{
var XMLLoader:URLLoader=new URLLoader(new URLRequest(“http://[localHost]/_vti_bin/owssvr.dll?Cmd=Display&List={80D18622-447F-4900-90A5-E424EDB95DCD}&XMLDATA=TRUE”))
XMLLoader.addEventListener(Event.COMPLETE,openXMLValues)
function openXMLValues(e:Event):void
{
var XMLL:XMLList=new XMLList(e.target.data)
var rsNS:Namespace = XMLL.namespace(“rs”);// Create Namespace inorder to access the XML node <rs:>
var zNS:Namespace = XMLL.namespace(“z”);// Create Namespace inorder to access the XML node <z:
var sNS:Namespace = XMLL.namespace(“s”); // Create Namespace inorder to access the XML node <s:
var FinalXML:XMLList=new XMLList(XMLL.rsNS::data.zNS::row) // access the node <rs:row>
Alert.show(FinalXML.@ows_LinkTitle)
}
}]]>
</mx:Script>
</mx:Application>

URLLoader  

The URLLoader class downloads data from a URL as text, binary data, or
URL-encoded variables. It is useful for downloading text files, XML, or other
information to be used in a dynamic, data-driven application.

var XMLLoader:URLLoader=new URLLoader(new URLRequest(“http://[localHost]/_vti_bin/owssvr.dll?Cmd=Display&List={80D18622-447F-4900-90A5-E424EDB95DCD}&XMLDATA=TRUE“))

XMLLoader.addEventListener(Event.COMPLETE,openXMLValues)

XMLList  

The XMLList class contains methods for working with one or more XML elements. An
XMLList object can represent one or more XML objects or elements (including
multiple nodes or attributes), so you can call methods on the elements as a
group or on the individual elements in the collection.

var XMLL:XMLList=new XMLList(e.target.data)

XMLL will have the entire XML elements including all attributes and nodes.

RecordSet XML vs Normal XML  

RecordSet XML

<xml 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’>
<s:Schema id=’RowsetSchema’>
<s:ElementType name=’row’ content=’eltOnly’ rs:CommandTimeout=’30’>
<s:AttributeType name=’ID’ rs:number=’1′>
<s:datatype dt:type=’int’ dt:maxLength=’4′ rs:precision=’10’ rs:fixedlength=’true’ rs:maybenull=’false’/>
</s:AttributeType>
<s:AttributeType name=’c1′ rs:name=’Status Code’ rs:number=’2′rs:writeunknown=’true’>
<s:datatype dt:type=’string’ dt:maxLength=’20’ rs:fixedlength=’true’ rs:maybenull=’false’/>
</s:AttributeType>
<s:extends type=’rs:rowbase’/>
</s:ElementType>
</s:Schema>
<rs:data><z:row ID=’1′ c1=’Add ‘/>
<z:row ID=’2′ c1=’Drop ‘/>
<z:row ID=’3′ c1=’Modify Date ‘/>
<z:row ID=’4′ c1=’Complete ‘/>
<z:row ID=’5′ c1=’Modify Parameters ‘/>
</rs:data>
</xml>

In order to access <z:row> recordset, you need to create Namespace for z: , rs:
, s: ,etc..,

var XMLL:XMLList=new XMLList(e.target.data)
var rsNS:Namespace = XMLL.namespace(“rs”);// Create Namespace inorder to access
the XML node <rs:>
var zNS:Namespace = XMLL.namespace(“z”); // Create Namespace inorder to access the XML node <z:
var sNS:Namespace = XMLL.namespace(“s”); // Create Namespace inorder to access the XML node <s:
var FinalXML:XMLList=new XMLList(XMLL.rsNS::data.zNS::row) // access the node <rs:row>
Alert.show(FinalXML.@ows_LinkTitle)

Normal XML

<xml >
<data>
<row ID=’1′ c1=’Add ‘/>
<row ID=’2′ c1=’Drop ‘/>
<row ID=’3′ c1=’Modify Date ‘/>
<row ID=’4′ c1=’Complete ‘/>
<row ID=’5′ c1=’Modify Parameters ‘/>
</data>
</xml>

var XMLL:XMLList=new XMLList(e.target.data)
var FinalXML:XMLList=new XMLList(XMLL.data.row)
Alert.show(FinalXML.@ows_LinkTitle)