Kev O. Kev O. - 1 month ago 8x
Javascript Question

jQuery html() does ignore element naming (lower and bigger case)

The .html() function from jQuery does turn my XML Code to lowercase.

Is there any other method so I can receive exactly the output which I am expecting?

html = $('pre').html();

Goal is to receive the following output:

<ok:List Title="HelloWorld"></ok>

What I receive:

<ok:list title="HelloWorld"></ok>

Complete Code:

<!DOCTYPE html>
<script src=""></script>
var html = $('pre').html();
<ok:List Title="HelloWorld"></ok>

I know that XML Standard is lowercase. However in my situation I can't change that xml part. So I need a solution so I can have even the wrong.xml displayed 'wrongly'.


Check out this fiddle.

It's not standard but if you put your XML into a textarea you can retrieve it via .val();

i.e. your HTML could look like:

<textarea id="my-xml">

Then in your javascript/jQuery:

var myxml = $('#my-xml').val(); //my will have case sensitive XML

Found here.