I have some data in string -
var xml = "<rss version='2.0'><channel><title>RSS Title</title></channel> </rss>" ;
Now I want this string to be display on web page in proper xml format .
<channel>
<title>
RSS Title
</title>
</channel>
How can I do this?
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">
<pre class="prettyprint lang-xml"></pre>
</div>
App.directive('prettyprint', function() {
return {
restrict: 'C',
link: function postLink(scope, element, attrs) {
element.text(vkbeautify.xml(scope.dom, 4));
}
};
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With