admin管理员组

文章数量:1402146

I want to add the attribute trust to one XML. My problem is that currently I have the value as a string, so I can not use the following code:

trusted (escaped) {
  escape.filter('to_trusted', ['$sce', function($sce) {
    return function(text) {
      return $sce.trustAsHtml(text);
    }
  }]);
} 

Is it possible to convert a string into a XML? I would like to convert escaped.

I want to add the attribute trust to one XML. My problem is that currently I have the value as a string, so I can not use the following code:

trusted (escaped) {
  escape.filter('to_trusted', ['$sce', function($sce) {
    return function(text) {
      return $sce.trustAsHtml(text);
    }
  }]);
} 

Is it possible to convert a string into a XML? I would like to convert escaped.

Share Improve this question edited Jan 25, 2018 at 14:49 Marouen Mhiri 1,6671 gold badge15 silver badges20 bronze badges asked Jan 25, 2018 at 14:36 bellotasbellotas 2,4719 gold badges35 silver badges67 bronze badges 0
Add a ment  | 

1 Answer 1

Reset to default 5

Yes, it is possible to convert a string into an XML. You need to use the DOMParser Class. Try something like this to convert:

let parser = new DOMParser();
let xml = parser.parseFromString( escaped, "text/xml");

本文标签: String to XMLJavascriptStack Overflow