0

I am getting json response from server through ajax call. One parameter in json contain xml. But when i set the content of that parameter to div it is not showing xml data. How can i show the xml content in div and if possible formatted xml data.

dmay
  • 1,305
  • 6
  • 21
  • 31

1 Answers1

1
  • Don't set the XML as the innerHTML. Create an inner text node, e.g.

    elem.appendChild( document.createTextNode(yourXmlString) );
    
  • Google Code Prettify could help

ComFreek
  • 29,044
  • 18
  • 104
  • 156
  • Now i am able to show xml in div and using [link]https://vkbeautify.googlecode.com/files/vkbeautify.0.99.00.beta.js i can properly indent xml. Google prettify is also very good but its only style content while page loading. I wasn't able to find how to prettify javascript function on button click. – dmay Sep 15 '13 at 21:26
  • @dmay Take a look here: http://stackoverflow.com/questions/15983894/dynamic-google-code-prettify-doesnt-work – ComFreek Sep 16 '13 at 16:46