Reputation: 2461
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
.
Upvotes: 5
Views: 6921
Reputation: 973
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");
Upvotes: 5