Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here's my <strong>javascript</strong> function that changes style to xml-key-words!! (unfortunately it doesn't indent xml) It accepts plain XML text as input, and return HTML styled code, with xml as text, coloring XML keywords with different colors as in an editor.</p> <pre><code>function stylizeXML(xml) { xml = xml.replace(/&gt;/g,"&amp;gt"); xml = xml.replace(/&lt;/g,"&amp;lt"); xml = xml.replace(/\&amp;gt\&amp;lt/g, "&amp;gt &lt;br&gt; &amp;lt"); // &gt;&lt; becomes &gt; &lt;br&gt; &lt; var greens=xml.match(/&lt;(\S+\s+)+[\S]+\=\"[^&gt;]+&gt;/g); // ...= for (i=0; i&lt;greens.length; i++) { greens=xml.match(/\s+\S+\=\"/g); for (i=0; i&lt;greens.length; i++) { green = greens[i]; green = green.replace(/\=\"/g, '=&lt;/span&gt;"'); attributes = green.match(/\s+\S+\=&lt;\/span&gt;\"/g); for(j=0; j&lt;attributes.length; j++) { attribute2 = "&lt;span class='color_green'&gt;"+attributes[j]; green = green.replace(attributes[j], attribute2); } xml = xml.replace(greens[i], green); } } var blues=xml.match(/\&amp;lt(.*?)\&amp;gt/g); // &lt; ... &gt; for (i=0; i&lt;blues.length; i++) { blue = blues[i]; blue = blue.replace("&amp;lt/",""); blue = blue.replace("&amp;lt",""); blue = blue.replace("&amp;gt",""); if (blues[i].match(/^\&amp;lt\//)) // &lt;/ ... &gt; {xml = xml.replace(blues[i], "&lt;span class='color_orange'&gt;&amp;lt/&lt;/span&gt;&lt;span class='color_blue'&gt;"+blue+"&lt;/span&gt;&lt;span class='color_orange'&gt;&amp;gt&lt;/span&gt;");} // &lt;/ else // &lt; ... &gt; {xml = xml.replace(blues[i], "&lt;span class='color_orange'&gt;&amp;lt&lt;/span&gt;&lt;span class='color_blue'&gt;"+blue+"&lt;/span&gt;&lt;span class='color_orange'&gt;&amp;gt&lt;/span&gt;");} } var reds=xml.match(/\=&lt;\/span&gt;(\s*)\"(.*?)\"/g); // ="..." for (i=0; i&lt;reds.length; i++) { red = reds[i]; red = red.replace("=&lt;/span&gt;",""); xml = xml.replace(reds[i], "=&lt;/span&gt;&lt;span class='color_red'&gt;"+red+"&lt;/span&gt;"); } return xml; } </code></pre> <p>here's the CSS associated:</p> <pre><code>&lt;style type="text/css"&gt; .color_orange {color :rgb(255,96,24);} .color_blue {color :blue;} .color_red {color :rgb(234, 49, 176);} .color_green {color : rgb(72,150,163);} &lt;/style&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload