JQuery html () ignores element names (lower and larger size)

The .html () function from jQuery turns my XML code into lowercase.

Is there any other method, so I can get exactly the result that I expect?

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

The goal is to get the following conclusion:

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

What I get:

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

The code:

<!DOCTYPE html>
<html>
<head>
  <title>Test</title>
    <script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
    <script>
    $(document).ready(function(){
      var html = $('pre').html();
      console.log(html);
    });
    </script>
</head>
<body>
<pre>
  <ok:List Title="HelloWorld"></ok>
</pre>
</body>
</html>

I know that the XML standard is lowercase. However, in my situation, I cannot change this part of the xml. So I need a solution so that I can even make mistakes. Xml is displayed "incorrectly."

+4
source share
1 answer

Check this script .

This is not standard, but if you put your XML in a text box, you can get it through .val();

. HTML- :

<textarea id="my-xml">
   <Example>
      <Node>Text</Node>
   </Example>
</textarea>

javascript/jQuery:

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

.

0

Source: https://habr.com/ru/post/1653913/


All Articles