Expand my Community achievements bar.

Select SOAP XML nodes from a XMLList in a DataGrid

Avatar

Level 1
Hi Flex Community,



I have a web service with a SOAP response (XML Document) and
store the result in a XMLList. Here the SOAP response:




<method:ReportListResponse xmlns:xsd="
http://www.w3.org/2001/XMLSchema"
xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENV="
http://schemas.xmlsoap.org/soap/envelope/"
xmlns:sql="
http://schemas.microsoft.com/sqlserver/2004/SOAP"
... xmlns:method="
http://<servername>/Server
Objects/Endpoints/SOAP">

<method:ReportListResult>

<sqlresultstream:SqlRowSet
xsi:type="sqlsoaptypes:SqlRowSet"
msdata:UseDataSetSchemaOnly="true"
msdata:UDTColumnValueWrapped="true">

<xsd:schema targetNamespace="
http://schemas.microsoft.com/sqlserver/2004/sqltypes">

<xsd:simpleType name="varchar">

<xsd:restriction base="xsd:string"/>

</xsd:simpleType>

</xsd:schema>

<xsd:schema
targetNamespace="urn:schemas-microsoft-com:sql:SqlRowSet1"
elementFormDefault="qualified">

<xsd:import namespace="
http://schemas.microsoft.com/sqlserver/2004/sqltypes"/>

<xsd:element name="SqlRowSet1" msdata:IsDataSet="true"
msdata:DataSetNamespace="urn:schemas-microsoft-com:sql:SqlDataSet"
msdata:DataSetName="SqlDataSet">

<xsd:complexType>

<xsd:sequence>

<xsd:element name="row" minOccurs="0"
maxOccurs="unbounded">

<xsd:complexType>

<xsd:sequence>

<xsd:element name="NAME" minOccurs="0">

<xsd:simpleType>

<xsd:restriction base="sqltypes:varchar"
sqltypes:localeId="1033" sqltypes:sqlCompareOptions="IgnoreCase
IgnoreKanaType IgnoreWidth" sqltypes:sqlSortId="52">

<xsd:maxLength value="255"/>

</xsd:restriction>

</xsd:simpleType>

</xsd:element>

</xsd:sequence>

</xsd:complexType>

</xsd:element>

</xsd:sequence>

</xsd:complexType>

</xsd:element>

</xsd:schema>

<diffgr:diffgram
xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">

<SqlRowSet1
xmlns="urn:schemas-microsoft-com:sql:SqlRowSet1">

<row>

<NAME>OTTO</NAME>

</row>

<row>

<NAME>ANNA</NAME>

</row>

...

</SqlRowSet1>

</diffgr:diffgram>

</sqlresultstream:SqlRowSet>

<sqlresultstream:SqlRowCount
xsi:type="sqlrowcount:SqlRowCount">

<sqlrowcount:Count>

31

</sqlrowcount:Count>

</sqlresultstream:SqlRowCount>

<sqlresultstream:SqlResultCode
xsi:type="sqlsoaptypes:SqlResultCode">

0

</sqlresultstream:SqlResultCode>

</method:ReportListResult>

</method:ReportListResponse>




I want to select the needed rows and output the results in a
datagrid:




private function webServiceResult(event:ResultEvent):void

{

trace("Ergebnis erhalten");

// create a XML object for result

var ResultXML:XML = (XML)(event.result);

//var th:Namespace = ResultXML.namespace();

//ResultXML.setNamespace(th);



// search the xml structure an d find the SqlRowSet1 tag

var sqlSet:XMLList = ResultXML.descendants("row");



trace("test=" + ResultXML.toString());

var ResultRows:XMLList = ResultXML.elements("NAME");

// output the identified rows

trace("#rows=" + ResultRows.length());



dataGridItems.removeAll();

// put all identified items ...

for each(var item:XML in ResultRows)

{

// ... in datagrid rows

dataGridItems.addItem(

{

COMPOUND_NAME: item.COMPOUND_NAME

});

}

}

<mx:DataGrid id="listRowsOutput"
dataProvider="{dataGridItems}" x="353" y="108" width="134">

<mx:columns>

<mx:DataGridColumn headerText="COMPOUND_NAME"
dataField="COMPOUND_NAME"/>

</mx:columns>

</mx:DataGrid>





The FlexBuilder has the xml structure but stores nothing in
the XMLList (Trace: rows = 0). Could anybody help me and describe
how I get the required tags?



Thx
0 Replies