Quantcast
Channel: SCN : All Content - SAPUI5 Developer Center
Viewing all articles
Browse latest Browse all 6178

How to retrieve data in XML view/ getProperty in controller from a XML Model?

$
0
0

I have a problem in dealing with the XML model, I can't retrieve the model data in the XML view and I can't get any property from the controller.

Here is the XML document retrieved from the URL:

<GetUsersResponsexmlns="http://tempuri.org/">

          <a:User>
               <a:Age>22</a:Age>

               <a:Id>2</a:Id>

               <a:Name>Ahmad</a:Name>

          </a:User>

          <a:User>
               <a:Age>24</a:Age>

               <a:Id>3</a:Id>

               <a:Name>Hussam</a:Name>

          </a:User>

</GetUsersResult>

</GetUsersResponse>

Here is the Code:

var oModel=new sap.ui.model.xml.XMLModel();

  var aData = jQuery.ajax({

            type : "GET",

            contentType : "text/xml; charset=\"utf-8\"",

            url : "http://localhost:8745/UsersService/users",

            dataType : "text",

            async: false,

            success : function(data,textStatus, jqXHR) {

                oModel.setXML(data);  

            }

});

The XML was set to the Model correctly but I can't deal with it I also used oModel.loadData("http://localhost:8745/UsersService/users","",false); but it didn't work. I was trying to get a property using oModel.getProperty("/User/Name"); also tried "/User/Name/text()" but neither of them worked.

 

I tried to bind the model data in to a list in the XML view using the following code:

<List  id="list"  mode="{device>/listMode}"  select="handleListSelect"  items="{/User}" >

  <ObjectListItem  type="{device>/listItemType}"  press="handleListItemPress"  title="{Name}" >

  </ObjectListItem>

</List>

I also tried "{Name/text()}", but also it didn't worked for me.

I would be grateful if anyone could help me to get this done.


Regards,

Ahmed ElManawy,


Viewing all articles
Browse latest Browse all 6178

Trending Articles



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