1

I have a template fragment file, which is an xml file in fact.

I want to load it in my controller, do some modification on that, and then use it to render some part of the view.

I only need to read this xml file as text file and put its content in a string.

I cannot find any object for doing this in SAPUI5 api.

Please note the file is placed in my view folder in server side.

I need some kind of promise that read the file and after reading the file run a successor function.

Thanks in advance

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
MJBZA
  • 4,796
  • 8
  • 48
  • 97

1 Answers1

0

There can be multiple ways to to this.

1.Either you can load your XML in an XML Model "sap.ui.model.xml.XMLModel()"

var oModelX = new sap.ui.model.xml.XMLModel(); 
oModelX.attachRequestCompleted(function(){
    var xmlStr =  oModelX.getXML();
    console.log(xmlStr); // Do what ever you want with your xml string 
}); 
oModelX.loadData("../view/st.fragment.xml");

2.You can also read the content of that XML file using AJAX and do your parsing in AJAX response.

DazBaldwin
  • 4,125
  • 3
  • 39
  • 43
Piyush aggarwal
  • 750
  • 2
  • 14
  • 25