I have the following string in Javascript and need to remove the <?xml ... ?>
and <!DOCTYPE .... ]>
tags. Can not convert it to a dom because the BR tags error as not being closed - and not able to edit the actual content.
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html [<!ENTITY amp "&#38;">]><div>Blah<br> Blah</div>
Trying to do it with .replace but can't quite seem to get there
text.replace(/\<\?xml.+\?\>/g, '');
Your replace()
works for the <?xml ... ?>
part.
To remove the <!DOCTYPE .... ]>
part as well you can do:
text.replace(/\<\?xml.+\?\>|\<\!DOCTYPE.+]\>/g, '');
As you can see here: http://jsfiddle.net/darkajax/9fKnd/1/
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