Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

XMLModel - Getting fields out of xml-table

Hi!

I have an XML-Model over an ltap-table.

How do I get the fields out of an XML-Model?


The easiest way would be if I would be able to just write:


oData.ltap[0].tanum


but it doesn´t work.


So how can I do it?




Here is my sourcecode:


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

jQuery(function($) {

  var oParameters = {

    h_app_methode : "TEST123",

  };

  oModel.loadData("sapui5_seite.xml", oParameters, false, 'POST');

  sap.ui.getCore().setModel(oModel);

  oModel.updateBindings(true);

  var oData = oModel.getObject("/asx:values/TABLE");

and here is the output of sapui5_seite.xml:

<?xml version="1.0" encoding="utf-16"?>

<asx:abap

    xmlns:asx="http://www.sap.com/abapxml" version="1.0">

    <asx:values>

        <TABLE>

            <LTAP>

                ...

                <TANUM>0000000001</TANUM>

                ...

            </LTAP>

            <LTAP>

                ...

                <TANUM>0000000002</TANUM>

                ...

            </LTAP>

        </TABLE>

    </asx:values>

</asx:abap>

Tags:
Former Member
replied

var data = [];

  $(oModel.getData().documentElement).find("LTAP").map(function(i, ltap){

var arr = data[i] = [];

  $(ltap).children().map(function(i, tanum){

  arr[tanum.localName] = ($(tanum).text());

  });

  });

data[0].TANUM

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question