How to print pretty xml in javascript?

后端 未结 5 700
你的背包
你的背包 2021-01-13 23:07

What\'s the best way to pretty-print xml in JavaScript? I obtain xml content through ajax call and before displaying this request in textarea i want to format it so it looks

5条回答
  •  旧巷少年郎
    2021-01-13 23:54

    This is not the best way to do this but you can get the xml as text and use RegExp to find and replace '>' with tabs according to the depth of the node and breaklines but I don't really know RegExp very well, sorry.

    You can also use XSLT and transform it using javascript.
    Check this link and take a look at this tutorial.

提交回复
热议问题