5

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.

0

1 Answer 1

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");
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.