1

I am using the following javascript replace function while formatting my xml code.

xml = xmll.replace(/<\/?[0-9]{1,}>/g, '');

But it is not creating line break even i used the following function too to create new line.

xml = xmll.replace(/<\/?[0-9]{1,}>/g, '\n');

Still it did nt create line break or new line after closing tags of xml. Can anybody know what should be the possible solution?

1 Answer 1

2

Try this.

xml = xmll.replace(/(<\/?.*?>)/g, '$1\n');
Sign up to request clarification or add additional context in comments.

6 Comments

Respected sir, it is really working. but sir, i was eliminating <0> tag but now <0> tag is again showing. as i dnt want to display node indexes such as <0> <1> and so on.
Then try this one. xml = xmll.replace(/(<\/?.*?>)/g, '\n');
Thanks sir, its also working but now it eliminating all of the closing and ending tags. but i want to eliminate or replace only <0> </0> <1> </1> tags and so on all the indexes. but not my xml tags such as <body></body>.
and can you explain this expression so i may able to produce my own according to my requirement. would be thankful.
Actullay it's same as [0-9]{1,} but it check for any characters not only digits. if my regex is working then your regex should also work. there is no difference .
|

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.