Skip to content Skip to sidebar Skip to footer

How To Display Xml Text In Html In Angular Js

I have some data in string - var xml = 'RSS Title' ; Now I want this string to

Solution 1:

Was expecting google-code-prettify would do the job but looks like it does not do indentation. With an additional plugin for indentation (vkbeautify) able to get the proper xml format with indentation.

http://plnkr.co/edit/Pep9HurLI8NPtAXRsoFD?p=preview

<div ng-controller="myCtrl">
  <preclass="prettyprint lang-xml"></pre>
</div>

App.directive('prettyprint', function() {
  return {
    restrict: 'C',
    link: functionpostLink(scope, element, attrs) {
          element.text(vkbeautify.xml(scope.dom, 4));
    }
  };
});

Post a Comment for "How To Display Xml Text In Html In Angular Js"