{"id":63930,"date":"2024-06-15T03:01:11","date_gmt":"2024-06-14T17:01:11","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/ITblog\/?p=63930"},"modified":"2024-06-14T22:40:50","modified_gmt":"2024-06-14T12:40:50","slug":"xml-lint-validation-onclick-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/xml-lint-validation-onclick-tutorial\/","title":{"rendered":"XML Lint Validation Onclick Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"https:\/\/www.rjmprogramming.com.au\/PHP\/xmllint_validation.php\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"XML Lint Validation Onclick Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/xmllint_validation_colour_coded_linear_gradient_background.jpg\" title=\"XML Lint Validation Onclick Tutorial\"  style=\"float:left;\" \/><\/a><p class=\"wp-caption-text\">XML Lint Validation Onclick Tutorial<\/p><\/div>\n<p>Onto yesterday&#8217;s <a title='XML Lint Validation Browsing Tutorial' href='#xmllvbt'>XML Lint Validation Browsing Tutorial<\/a> XML Lint Validation web application progress, today, we start to add some onclick and ondblclick event logic to those left hand table cell pair of textarea elements &#8230;<\/p>\n<p>&lt;?php echo &#8221;<br \/>\n<code><br \/>\nfunction gcbr() {<br \/>\n  if (rowseq != '') {<br \/>\n   s1rect=s1.getBoundingClientRect();<br \/>\n   s1.onclick=function(event) { s1click(event);  };<br \/>\n   s1.ondblclick=function(event) { alert('Line ' + s1.title + s1.getAttribute('data-status') + ':' + String.fromCharCode(10) + s2.title);  };<br \/>\n   s2rect=s2.getBoundingClientRect();<br \/>\n   s2.onclick=function(event) { s2click(event);  };<br \/>\n   s2.ondblclick=function(event) { alert('Line ' + s1.title + s1.getAttribute('data-status') + ':' + String.fromCharCode(10) + s2.title);  };<br \/>\n  }<br \/>\n  <br \/>\n  if (('' + location.hash).replace(\/^null\/g,'').replace(\/^undefined\/g,'').trim() != '') {<br \/>\n   if (document.getElementById('myhxfile').value == '') {<br \/>\n     document.getElementById('myhxfile').placeholder=decodeURIComponent(('' + location.hash).replace(\/^\\#\/g,''));<br \/>\n     var tf=document.getElementById('outgoing').value;<br \/>\n     var tfis=tf.split(':')[0];<br \/>\n     if (tfis.trim() != '') {<br \/>\n       while (tf.indexOf(tfis + ':') != -1) {<br \/>\n         tf=tf.replace(tfis + ':', decodeURIComponent(('' + location.hash).replace(\/^\\#\/g,'')) + ':');<br \/>\n       }<br \/>\n       document.getElementById('outgoing').value=tf;<br \/>\n     }<br \/>\n   }<br \/>\n  }<br \/>\n}<br \/>\n<\/code><br \/>\n&#8220;; ?&gt;<\/p>\n<p> &#8230; and though we usually do not associate onclick logic with textarea elements, today we&#8217;re preferring that to any alternate use of div element alternative because, today, for the first time, we&#8217;re making use of the <i>\u201csharp\u201d colour stops<\/i> mentioned by <a target=_blank href=\"https:\/\/tympanus.net\/codrops\/css_reference\/linear-gradient\/\">linear-gradient()<\/a>, thanks &#8230;<\/p>\n<p>&lt;?php echo &#8221;<br \/>\n<code><br \/>\nfunction s1click(e) {<br \/>\n       var theheight=eval(eval('' + s1rect.height) \/ rowseq);<br \/>\n       var codelines=s2.value.split(String.fromCharCode(10));<br \/>\n       var errdetail='', ierr=0, linenum=0;<br \/>\n       if (e.touches) {<br \/>\n       if (e.touches[0].pageX) {<br \/>\n       x1=(eval(e.touches[0].pageX + document.body.scrollLeft * 1) * 1);<br \/>\n       y1=(eval(e.touches[0].pageY + eval(eval(e.touches[0].pageY % theheight) - theheight) + document.body.scrollTop * 1) * 1);<br \/>\n       linenum=Math.floor(eval(1 + eval(eval(e.touches[0].pageY + document.body.scrollTop - s1rect.top) \/ theheight)));<br \/>\n       } else {<br \/>\n       x1=(eval(e.touches[0].clientX + document.body.scrollLeft * 1) * 1);<br \/>\n       y1=(eval(e.touches[0].clientY + eval(eval(e.touches[0].clientY % theheight) - theheight) + document.body.scrollTop * 1) * 1);<br \/>\n       linenum=Math.floor(eval(1 + eval(eval(e.touches[0].clientY + document.body.scrollTop - s1rect.top) \/ theheight)));<br \/>\n       }<br \/>\n       } else if (e.clientX || e.clientY) {<br \/>\n        x1=(e.clientX + document.body.scrollLeft * 1);<br \/>\n        y1=(e.clientY + eval(eval(e.clientY % theheight) - theheight) + document.body.scrollTop * 1);<br \/>\n        linenum=Math.floor(eval(1 + eval(eval(e.clientY + document.body.scrollTop - s1rect.top) \/ theheight)));<br \/>\n       } else {<br \/>\n        x1=(e.pageX + document.body.scrollLeft * 1);<br \/>\n        y1=(e.pageY + eval(eval(e.pageY % theheight) - theheight) + document.body.scrollTop * 1);<br \/>\n        linenum=Math.floor(eval(1 + eval(eval(e.pageY + document.body.scrollTop - s1rect.top) \/ theheight)));<br \/>\n       }<br \/>\n       \/\/alert('' + linenum + ' ' + y1 + '\/' + document.body.scrollTop + ' ... ' + s1.scrollTop + ' ... ' + s1rect.top + '\/' + s1rect.y + ' +++ ' + theheight);<br \/>\n       var finds=document.getElementById('outgoing').value.split(':' + linenum + ':');<br \/>\n       thergb=greenrgb;<br \/>\n       s1.setAttribute('data-status', '');<br \/>\n       if (eval('' + finds.length) &gt; 1) {<br \/>\n       for (ierr=1; ierr&lt;finds.length; ierr++) {<br \/>\n         errdetail+=String.fromCharCode(10) + finds[eval(-1 + ierr)].split(':' + linenum + ':')[0].split(String.fromCharCode(10))[eval(-1 + finds[eval(-1 + ierr)].split(':' + linenum + ':')[0].split(String.fromCharCode(10)).length)] + ':' + linenum + ':' + finds[eval(0 + ierr)].split(String.fromCharCode(10))[0];<br \/>\n       }<br \/>\n       errdetail+=String.fromCharCode(10);<br \/>\n       thergb=redrgb;<br \/>\n       s1.setAttribute('data-status', ' (has errors ... ' + errdetail + ' ... over to the right)');<br \/>\n       }<br \/>\n       s1.title='' + linenum;<br \/>\n       s2.title='' + codelines[eval(-1 + linenum)];<br \/>\n       y1-=eval('' + s1rect.top);<br \/>\n       \/\/ linear-gradient(to right, yellow, yellow 20%, #009966 20%, #009966 80%, purple 80%, purple);<br \/>\n       \/\/alert('linear-gradient(to bottom, white, white ' + y1 + 'px, ' + thergb + ' ' + y1 + 'px, ' + thergb + ' ' + eval(y1 + eval('' + s2rect.height) \/ rowseq) + 'px,  white ' + eval(y1 + eval('' + s2rect.height) \/ rowseq) + 'px, white)');<br \/>\n       s2.style.backgroundImage='linear-gradient(to bottom, white, white ' + y1 + 'px, ' + thergb + ' ' + y1 + 'px, ' + thergb + ' ' + eval(y1 + eval('' + s2rect.height) \/ rowseq) + 'px,  white ' + eval(y1 + eval('' + s2rect.height) \/ rowseq) + 'px, white)';<br \/>\n       s1.style.backgroundImage='linear-gradient(to bottom, white, white ' + y1 + 'px, ' + thergb + ' ' + y1 + 'px, ' + thergb + ' ' + eval(y1 + eval('' + s2rect.height) \/ rowseq) + 'px,  white ' + eval(y1 + eval('' + s2rect.height) \/ rowseq) + 'px, white)';<br \/>\n}<br \/>\n<br \/>\nfunction s2click(e) {<br \/>\n       var theheight=eval(eval('' + s2rect.height) \/ rowseq);<br \/>\n       var codelines=s2.value.split(String.fromCharCode(10));<br \/>\n       var errdetail='', ierr=0, linenum=0;<br \/>\n       if (e.touches) {<br \/>\n       if (e.touches[0].pageX) {<br \/>\n       x2=(eval(e.touches[0].pageX + document.body.scrollLeft * 1) * 1);<br \/>\n       y2=(eval(e.touches[0].pageY + eval(eval(e.touches[0].pageY % theheight) - theheight) + document.body.scrollTop * 1) * 1);<br \/>\n       linenum=Math.floor(eval(1 + eval(eval(e.touches[0].pageY + document.body.scrollTop - s2rect.top) \/ theheight)));<br \/>\n       } else {<br \/>\n       x2=(eval(e.touches[0].clientX + document.body.scrollLeft * 1) * 1);<br \/>\n       y2=(eval(e.touches[0].clientY + eval(eval(e.touches[0].clientY % theheight) - theheight) + document.body.scrollTop * 1) * 1);<br \/>\n       linenum=Math.floor(eval(1 + eval(eval(e.touches[0].clientY + document.body.scrollTop - s2rect.top) \/ theheight)));<br \/>\n       }<br \/>\n       } else if (e.clientX || e.clientY) {<br \/>\n        x2=(e.clientX + document.body.scrollLeft * 1);<br \/>\n        y2=(e.clientY + eval(eval(e.clientY % theheight) - theheight) + document.body.scrollTop * 1);<br \/>\n        linenum=Math.floor(eval(1 + eval(eval(e.clientY + document.body.scrollTop - s2rect.top) \/ theheight)));<br \/>\n       } else {<br \/>\n        x2=(e.pageX + document.body.scrollLeft * 1);<br \/>\n        y2=(e.pageY + eval(eval(e.pageY % theheight) - theheight) + document.body.scrollTop * 1);<br \/>\n        linenum=Math.floor(eval(1 + eval(eval(e.pageY + document.body.scrollTop - s2rect.top) \/ theheight)));<br \/>\n       }<br \/>\n       var finds=document.getElementById('outgoing').value.split(':' + linenum + ':');<br \/>\n       thergb=greenrgb;<br \/>\n       s1.setAttribute('data-status', '');<br \/>\n       if (eval('' + finds.length) &gt; 1) {<br \/>\n       for (ierr=1; ierr&lt;finds.length; ierr++) {<br \/>\n         errdetail+=String.fromCharCode(10) + finds[eval(-1 + ierr)].split(':' + linenum + ':')[0].split(String.fromCharCode(10))[eval(-1 + finds[eval(-1 + ierr)].split(':' + linenum + ':')[0].split(String.fromCharCode(10)).length)] + ':' + linenum + ':' + finds[eval(0 + ierr)].split(String.fromCharCode(10))[0];<br \/>\n       }<br \/>\n       errdetail+=String.fromCharCode(10);<br \/>\n       thergb=redrgb;<br \/>\n       s1.setAttribute('data-status', ' (has errors ... ' + errdetail + ' ... over to the right)');<br \/>\n       }<br \/>\n       s1.title='' + linenum;<br \/>\n       s2.title='' + codelines[eval(-1 + linenum)];<br \/>\n       y2-=eval('' + s2rect.top);<br \/>\n       s2.style.backgroundImage='linear-gradient(to bottom, white, white ' + y2 + 'px, ' + thergb + ' ' + y2 + 'px, ' + thergb + ' ' + eval(y2 + eval('' + s1rect.height) \/ rowseq) + 'px,  white ' + eval(y1 + eval('' + s1rect.height) \/ rowseq) + 'px, white)';<br \/>\n       s1.style.backgroundImage='linear-gradient(to bottom, white, white ' + y2 + 'px, ' + thergb + ' ' + y2 + 'px, ' + thergb + ' ' + eval(y2 + eval('' + s1rect.height) \/ rowseq) + 'px,  white ' + eval(y1 + eval('' + s1rect.height) \/ rowseq) + 'px, white)';<br \/>\n}<br \/>\n<\/code><br \/>\n&#8220;; ?&gt;<\/p>\n<p> to be able to add colour coding to (the background of) HTML textarea elements.<\/p>\n<p>Also, a hashtagging idea is implemented to aid with bringing over a browsed for file name into the &#8220;reporting mix&#8221; in <a target=_blank href=\"https:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?one=https:\/\/www.rjmprogramming.com.au\/PHP\/xmllint_validation.php--GETME\">our changed<\/a> <a target=_blank href=\"https:\/\/www.rjmprogramming.com.au\/PHP\/xmllint_validation.php--GETME\">&#8220;third draft&#8221;<\/a> <a target=_blank href=\"https:\/\/www.rjmprogramming.com.au\/PHP\/xmllint_validation.php_GETME\">xmllint_validation.php<\/a> <a target=_blank href=\"https:\/\/www.rjmprogramming.com.au\/PHP\/xmllint_validation.php\">you might want to try for yourself<\/a>.<\/p>\n<p><!--p>You can also see this play out at WordPress 4.1.1's <a target=_blank  href='\/\/www.rjmprogramming.com.au\/ITblog\/xml-lint-validation-onclick-tutorial\/'XML Lint Validation Onclick Tutorial<\/a>..<\/p-->\n<hr>\n<p id='xmllvbt'>Previous relevant <a target=_blank title='XML Lint Validation Browsing Tutorial' href='\/\/www.rjmprogramming.com.au\/ITblog\/xml-lint-validation-browsing-tutorial\/'>XML Lint Validation Browsing Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"https:\/\/www.rjmprogramming.com.au\/PHP\/xmllint_validation.php\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"XML Lint Validation Browsing Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/xmllint_validation_browse.jpg\" title=\"XML Lint Validation Browsing Tutorial\"  style=\"float:left;\" \/><\/a><p class=\"wp-caption-text\">XML Lint Validation Browsing Tutorial<\/p><\/div>\n<p>Yesterday&#8217;s <a title='XML Lint Validation Tutorial' href='#xmllvt'>XML Lint Validation Tutorial<\/a> had us starting out on a discovery tour of XML Lint, yesterday &#8230;<\/p>\n<ul>\n<li>starting with an HTML or XML URL of interest incoming data way &#8230; and today, we add onto that &#8230;<\/li>\n<li>a local HTML or XMLfile browsing means of defining your input data into &#8230;<\/li>\n<\/ul>\n<p> &#8230; <a target=_blank href=\"https:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?one=https:\/\/www.rjmprogramming.com.au\/PHP\/xmllint_validation.php-GETME\">our changed<\/a> <a target=_blank href=\"https:\/\/www.rjmprogramming.com.au\/PHP\/xmllint_validation.php-GETME\">&#8220;second draft&#8221;<\/a> <a target=_blank href=\"https:\/\/www.rjmprogramming.com.au\/PHP\/xmllint_validation.php_GETME\">xmllint_validation.php<\/a> <a target=_blank href=\"https:\/\/www.rjmprogramming.com.au\/PHP\/xmllint_validation.php\">you might want to try for yourself<\/a>, helped out by <a target=_blank href='https:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?one=https:\/\/www.rjmprogramming.com.au\/HTMLCSS\/client_browsing.html----------------------------------------GETME'>a tweaked<\/a> <a target=_blank href='https:\/\/www.rjmprogramming.com.au\/HTMLCSS\/client_browsing.html----------------------------------------GETME'>client_browsing.htm<\/a> client side HTML and Javascript inhouse helper.<\/p>\n<p>Again, we see, into another way to yesterday&#8217;s work, how useful is a textarea element, in that it can facilitate the way &#8230;<\/p>\n<ul>\n<li>HTML and XML data can be input via populating the textarea innerHTML attribute &#8230; which flows through to a &#8230;<\/li>\n<li>textarea value attribute value where any &lt; is mapped to &amp;lt; and &gt; is mapped to &amp;gt; &#8230; ready for &#8230;<\/li>\n<li>an HTML form hosted textarea, given a filled in <i>name<\/i> attribute be able to share this data to that form&#8217;s <i>action<\/i> attributed value &#8230;<br \/>\n&lt;?php<br \/>\n<code><br \/>\nfunction ronecheck() {<br \/>\n   if (document.getElementById('result1').innerHTML != '') {<br \/>\n      document.getElementById('incoming').innerHTML=document.getElementById('result1').value;<br \/>\n      document.getElementById('result1').innerHTML='';<br \/>\n      document.getElementById('result1').value='';<br \/>\n      document.getElementById('myhxfile').name='xx';<br \/>\n      document.getElementById('mysub').click();<br \/>\n   }<br \/>\n}<br \/>\n<\/code><br \/>\n?&gt;<br \/>\n &#8230; (in our case being the same PHP) &#8230;<\/li>\n<li>able to be processed by recall PHP interventional code &#8230;<br \/>\n&lt;?php<br \/>\n<code><br \/>\n $vsnone='none';<br \/>\n $prefn='Please enter either HTML or XML file to validate ...';<br \/>\n $pth='';<br \/>\n $rn='' .rand(1,78477554);<br \/>\n $results='';<br \/>\n $precontents='';<br \/>\n $contents='';<br \/>\n $fn='';<br \/>\n if (!isset($_GET['htmlfile']) && isset($_GET['content'])) {<br \/>\n   $_GET['htmlfile']=$_GET['content'];<br \/>\n }<br \/>\n if (!isset($_POST['htmlfile']) && isset($_POST['content'])) {<br \/>\n   $_POST['htmlfile']=$_POST['content'];<br \/>\n }<br \/>\n if (isset($_GET['htmlfile'])) {<br \/>\n   if (substr(trim(urldecode($_GET['htmlfile'])) . ' ', 0, 1) == '&lt;') {<br \/>\n   $contents=trim(str_replace('+',' ',urldecode($_GET['htmlfile'])));<br \/>\n   if (strpos(strtolower(explode('&gt;', $contents)[0]), 'html') !== false) {<br \/>\n   $fn='\/tmp\/html_' . $rn . '.html';<br \/>\n   } else if (strpos(strtolower(explode('&gt;', $contents)[0]), 'xml') !== false) {<br \/>\n   $fn='\/tmp\/xml_' . $rn . '.xml';<br \/>\n   }<br \/>\n   file_put_contents($fn, $contents);<br \/>\n   } else {<br \/>\n   $fn=str_replace('+',' ',urldecode($_GET['htmlfile']));<br \/>\n   }<br \/>\n   if ($fn != '') {<br \/>\n   if (strpos($fn, 'localhost') !== false) {<br \/>\n     $rhs=explode('localhost' . explode('\/', explode('localhost', $fn)[1])[0], $fn)[1];<br \/>\n     $fn=$_SERVER['DOCUMENT_ROOT'] . $rhs;<br \/>\n     $pth='\/usr\/bin\/';<br \/>\n   } else if (strpos($fn, 'rjmprogramming.com.au') !== false) {<br \/>\n     $rhs=explode('rjmprogramming.com.au' . explode('\/', explode('rjmprogramming.com.au', $fn)[1])[0], $fn)[1];<br \/>\n     $fn=$_SERVER['DOCUMENT_ROOT'] . $rhs;<br \/>\n   } else if (strpos($_SERVER['SERVER_NAME'], 'localhost') !== false) {<br \/>\n     $pth='\/usr\/bin\/';<br \/>\n   }<br \/>\n   }<br \/>\n   if (file_exists($fn)) {<br \/>\n   if ($contents == '') {<br \/>\n     $contents=file_get_contents($fn);<br \/>\n   }<br \/>\n   $prefn=$fn;<br \/>\n   $fn=realpath($fn);<br \/>\n if (strpos(strtolower($fn), '.xml') !== false) {<br \/>\n   $vsnone='block';<br \/>\n   $results=shell_exec($pth . 'xmllint --valid --noout ' . $fn . ' 2&gt; ' . ' ' . rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . 'xmllint.err');<br \/>\n   if (file_exists(rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . 'xmllint.err')) {<br \/>\n     $results.=\"\\n\";<br \/>\n     $results.=file_get_contents(rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . 'xmllint.err');<br \/>\n     unlink(rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . 'xmllint.err');<br \/>\n   }<br \/>\n } else if (strpos(strtolower($fn), '.htm') !== false) {<br \/>\n   $vsnone='block';<br \/>\n   $results=shell_exec($pth . 'xmllint --html --valid --noout ' . $fn . ' 2&gt; ' . ' ' . rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . 'xmllint.err');<br \/>\n   if (file_exists(rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . 'xmllint.err')) {<br \/>\n     $results.=\"\\n\";<br \/>\n     $results.=file_get_contents(rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . 'xmllint.err');<br \/>\n     unlink(rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . 'xmllint.err');<br \/>\n   }<br \/>\n }<br \/>\n   if (strpos($fn, '\/tmp\/') !== false) { unlink($fn);  }<br \/>\n   } else {<br \/>\n   $contents='';<br \/>\n   if (strpos($fn, '\/tmp\/') !== false) { unlink($fn);  }<br \/>\n   }<br \/>\n } else if (isset($_POST['htmlfile'])) {<br \/>\n   if (substr(trim(urldecode($_POST['htmlfile'])) . ' ', 0, 1) == '&lt;') {<br \/>\n   $contents=trim(str_replace('+',' ',urldecode($_POST['htmlfile'])));<br \/>\n   if (strpos(strtolower(explode('&gt;', $contents)[0]), 'html') !== false) {<br \/>\n   $fn='\/tmp\/html_' . $rn . '.html';<br \/>\n   } else if (strpos(strtolower(explode('&gt;', $contents)[0]), 'xml') !== false) {<br \/>\n   $fn='\/tmp\/xml_' . $rn . '.xml';<br \/>\n   }<br \/>\n   file_put_contents($fn, $contents);<br \/>\n   } else {<br \/>\n   $fn=str_replace('+',' ',urldecode($_POST['htmlfile']));<br \/>\n   }<br \/>\n   if ($fn != '') {<br \/>\n   if (strpos($fn, 'localhost') !== false) {<br \/>\n     $rhs=explode('localhost' . explode('\/', explode('localhost', $fn)[1])[0], $fn)[1];<br \/>\n     $fn=$_SERVER['DOCUMENT_ROOT'] . $rhs;<br \/>\n     $pth='\/usr\/bin\/';<br \/>\n   } else if (strpos($fn, 'rjmprogramming.com.au') !== false) {<br \/>\n     $rhs=explode('rjmprogramming.com.au' . explode('\/', explode('rjmprogramming.com.au', $fn)[1])[0], $fn)[1];<br \/>\n     $fn=$_SERVER['DOCUMENT_ROOT'] . $rhs;<br \/>\n   } else if (strpos($_SERVER['SERVER_NAME'], 'localhost') !== false) {<br \/>\n     $pth='\/usr\/bin\/';<br \/>\n   }<br \/>\n   }<br \/>\n   if (file_exists($fn)) {<br \/>\n   $prefn=$fn;<br \/>\n   if ($contents == '') {<br \/>\n     $contents=file_get_contents($fn);<br \/>\n   }<br \/>\n   $fn=realpath($fn);<br \/>\n if (strpos(strtolower($fn), '.xml') !== false) {<br \/>\n   $vsnone='block';<br \/>\n   $results=shell_exec($pth . 'xmllint --valid --noout ' . $fn . ' 2&gt; ' . ' ' . rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . 'xmllint.err');<br \/>\n   if (file_exists(rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . 'xmllint.err')) {<br \/>\n     $results.=\"\\n\";<br \/>\n     $results.=file_get_contents(rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . 'xmllint.err');<br \/>\n     unlink(rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . 'xmllint.err');<br \/>\n   }<br \/>\n } else if (strpos(strtolower($fn), '.htm') !== false) {<br \/>\n   $vsnone='block';<br \/>\n   $results=shell_exec($pth . 'xmllint --html --valid --noout ' . $fn . ' 2&gt; ' . ' ' . rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . 'xmllint.err');<br \/>\n   if (file_exists(rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . 'xmllint.err')) {<br \/>\n     $results.=\"\\n\";<br \/>\n     $results.=file_get_contents(rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . 'xmllint.err');<br \/>\n     \/\/file_put_contents('xxx.xxx', $results);<br \/>\n     unlink(rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . 'xmllint.err');<br \/>\n   }<br \/>\n }<br \/>\n   if (strpos($fn, '\/tmp\/') !== false) { unlink($fn);  }<br \/>\n   } else {<br \/>\n   $contents='';<br \/>\n   if (strpos($fn, '\/tmp\/') !== false) { unlink($fn);  }<br \/>\n   }<br \/>\n }<br \/>\n if ($contents != '') {<br \/>\n   $lines=explode(\"\\n\", $contents);<br \/>\n   for ($ii=1; $ii&lt;=sizeof($lines); $ii++) {<br \/>\n     $precontents.='' . $ii . \"\\n\";<br \/>\n   }<br \/>\n }<br \/>\n<\/code><br \/>\n?&gt;\n<\/ul>\n<p>Cute, huh?!<\/p>\n<p><!--p>You can also see this play out at WordPress 4.1.1's <a target=_blank  href='\/\/www.rjmprogramming.com.au\/ITblog\/new-xml-lint-validation-browsing-tutorial\/'>XML Lint Validation Browsing Tutorial<\/a>.<\/p-->\n<hr>\n<p id='xmllvt'>Previous relevant <a target=_blank title='XML Lint Validation Tutorial' href='\/\/www.rjmprogramming.com.au\/ITblog\/xml-lint-validation-tutorial\/'>XML Lint Validation Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"https:\/\/www.rjmprogramming.com.au\/PHP\/xmllint_validation.php\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"XML Lint Validation Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/xmllint_validation.jpg\" title=\"XML Lint Validation Tutorial\"  style=\"float:left;\" \/><\/a><p class=\"wp-caption-text\">XML Lint Validation Tutorial<\/p><\/div>\n<p>Do you remember when we discussed the Sanitizer API, talked about at <a title='Sanitizer API Primer Tutorial' href='#sapipt'>Sanitizer API Primer Tutorial<\/a>, regarding it as a web application HTML (and more) validation tool?<\/p>\n<p>Well, we&#8217;ve based a new &#8220;validator&#8221; of HTML or XML using the <a target=_blank title='xmllint on Linux information' href='https:\/\/linux.die.net\/man\/1\/xmllint'>XML Lint<\/a> web application on what we did then, but this code needing to be &#8230;<\/p>\n<ul>\n<li>under the auspices of a serverside scenario &#8230; ie. PHP &#8230; for us &#8230; calling on &#8230;<\/li>\n<li>underlying operating system call such as (for HTML qsall.htm incoming data file) &#8230;<br \/>\n<code><br \/>\nxmllint --html --valid --noout .\/qsall.htm<br \/>\n<\/code><br \/>\n &#8230; via &#8230;<\/li>\n<li><a target=_blank title='PHP shell_exec() method information' href='http:\/\/php.net\/manual\/en\/function.shell-exec.php'>shell_exec<\/a><\/li>\n<\/ul>\n<p> &#8230; there&#8217;s not much left of the original HTML and Javascript!<\/p>\n<p>We had a fun time with HTML textarea elements and scrolling with the resultant <a target=_blank href=\"https:\/\/www.rjmprogramming.com.au\/PHP\/xmllint_validation.php_GETME\">&#8220;first draft&#8221;<\/a> <a target=_blank href=\"https:\/\/www.rjmprogramming.com.au\/PHP\/xmllint_validation.php_GETME\">xmllint_validation.php<\/a> <a target=_blank href=\"https:\/\/www.rjmprogramming.com.au\/PHP\/xmllint_validation.php\">you might want to try for yourself<\/a> supplying an HTML or XML URL of intetest.  Why, in particular?  Well, it was the first time that we remember trying to make practically useful &#8230;<\/p>\n<ul>\n<li>a table cell (ie. td element) (the left of two) hosted &#8230;<\/li>\n<li>two textarea element arrangement whereby, ideally. they view &#8230;\n<ol>\n<li>side by side<\/li>\n<li>if one is scrolled the two identically scroll the same amount &#8230; <font size=1>(document.body outerHTML)<\/font> HTML &#8230;<br \/>\n&lt;?php echo &#8221;<br \/>\n<code><br \/>\n&lt;body onload=\"s1 = document.getElementById('preincoming'); s2 = document.getElementById('incoming'); s1.addEventListener('scroll', select_scroll_1, false); s2.addEventListener('scroll', select_scroll_2, false);\" data-onload='onl();'&gt;<br \/>\n&lt;h1&gt;XML Lint Validation &lt;!--button onclick='trythis();' title='Try your own'&gt;Usage&lt;\/button--&gt;&lt;\/h1&gt;<br \/>\n&lt;h3&gt;RJM Programming - June, 2024&lt;\/h3&gt;<br \/>\n&lt;form action=.\/xmllint_validation.php method=POST target=_self&gt;<br \/>\n&lt;table style=width:95%; border=5&gt;<br \/>\n&lt;tr&gt;&lt;th colspan=2 style=text-align:center;&gt;XML Lint validation of &lt;input style=width:70%; onblur=\"if (this.value.length &gt; 0) { document.getElementById('mysub').click();  }\" name=htmlfile id=myhxfile placeholder='Please enter either HTML or XML file to validate ...' value=\"&lt;?php echo str_replace('&gt;','&gt;',str_replace('&lt;','&lt;',$prefn)); ?&gt;\"&gt;&lt;\/input&gt;&lt;\/th&gt;&lt;\/tr&gt;<br \/>\n&lt;tr&gt;&lt;th&gt;Data to validate&lt;\/th&gt;&lt;th&gt;XML Lint results&lt;\/th&gt;&lt;\/tr&gt;<br \/>\n&lt;tr&gt;&lt;td style=vertical-align:top;&gt;&lt;textarea style=font-size:8px;display:inline-block;overflow-x:clip;text-wrap:nowrap;text-align:right; id=preincoming&gt;&lt;?php echo str_replace('&gt;','&gt;',str_replace('&lt;','&lt;',$precontents)); ?&gt;&lt;\/textarea&gt;&lt;textarea onblur=\"if (this.value.length &gt; 0 && '&lt;?echo $fn; ?&gt;' == '') { document.getElementById('mysub').click();  }\" style=font-size:8px;display:inline-block;overflow-x:clip;text-wrap:nowrap; name=content id=incoming&gt;&lt;?php echo str_replace('&gt;','&gt;',str_replace('&lt;','&lt;',$contents)); ?&gt;&lt;\/textarea&gt;&lt;\/td&gt;&lt;td style=vertical-align:top;&gt;&lt;textarea id=outgoing&gt;&lt;?php echo str_replace('&gt;','&gt;',str_replace('&lt;','&lt;',$results)); ?&gt;&lt;\/textarea&gt;&lt;\/td&gt;&lt;\/tr&gt;<br \/>\n&lt;tr&gt;&lt;td&gt;&lt;\/td&gt;&lt;td&gt;&lt;input type=submit id=mysub style=display:&lt;?php echo $vsnone; ?&gt; value=Validate&gt;&lt;\/input&gt;&lt;\/td&gt;&lt;\/tr&gt;<br \/>\n&lt;\/table&gt;<br \/>\n&lt;\/form&gt;<br \/>\n&lt;\/body&gt;<br \/>\n<\/code><br \/>\n&#8220;; ?&gt;<br \/>\n &#8230; uses Javascript &#8230;<br \/>\n&lt;?php echo &#8221;<br \/>\n<code><br \/>\nvar s1=null, s2=null;<br \/>\n<br \/>\n\/\/ Thanks to <a target=_blank href='https:\/\/stackoverflow.com\/questions\/7108270\/scrolling-2-different-elements-in-same-time' title='https:\/\/stackoverflow.com\/questions\/7108270\/scrolling-2-different-elements-in-same-time'>https:\/\/stackoverflow.com\/questions\/7108270\/scrolling-2-different-elements-in-same-time<\/a><br \/>\nfunction select_scroll_1(e) { s2.scrollTop = s1.scrollTop; }<br \/>\nfunction select_scroll_2(e) { s1.scrollTop = s2.scrollTop; }<br \/>\n<\/code><br \/>\n&#8220;; ?&gt;<br \/>\n&#8230; so that &#8230;<\/li>\n<li>the left hand textarea contains code line numbers right aligned &#8230; to sidle up next to &#8230;<\/li>\n<li>the right hand textarea contains the code (HTML or XML) being validated by xmllint<\/li>\n<\/ol>\n<p> &#8230; while &#8230;\n<\/li>\n<li>the right hand table cell contains the xmllint validation (of HTML or XML) results<\/li>\n<\/ul>\n<p> &#8230; had us, in practice, thanking our lucky stars that &#8230;<\/p>\n<ol>\n<li>textarea elements are resizeable<\/li>\n<li>you can simulate &#8220;some cockpit action&#8221; aligning them vertically &#8230; <a target=_blank title='?' href='https:\/\/www.youtube.com\/watch?v=0TiqXFssKMY'>Jim<\/a>?!<\/li>\n<\/ol>\n<p><!--p>You can also see this play out at WordPress 4.1.1's <a target=_blank  href='\/\/www.rjmprogramming.com.au\/ITblog\/xml-lint-validation-tutorial\/'>XML Lint Validation Tutorial<\/a>.<\/p-->\n<hr>\n<p id='sapipt'>Previous relevant <a target=_blank title='Sanitizer API Primer Tutorial' href='\/\/www.rjmprogramming.com.au\/ITblog\/sanitizer-api-primer-tutorial\/'>Sanitizer API Primer Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"https:\/\/www.rjmprogramming.com.au\/HTMLCSS\/sanitizer_api_test.html\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"Sanitizer API Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/sanitizer_api_test.jpg\" title=\"Sanitizer API Primer Tutorial\"  style=\"float:left;\" \/><\/a><p class=\"wp-caption-text\">Sanitizer API Primer Tutorial<\/p><\/div>\n<p>Today we&#8217;re roadtesting the <a target=_blank title='Sanitizer API' href='https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/HTML_Sanitizer_API'>Sanitizer API<\/a> &#8230;<\/p>\n<blockquote cite='https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/HTML_Sanitizer_API'><p>\nThe HTML Sanitizer API allow developers to take untrusted strings of HTML and Document or DocumentFragment objects, and sanitize them for safe insertion into a document&#8217;s DOM.\n<\/p><\/blockquote>\n<p> &#8230; as another validation idea for HTML to add to our previous <a target=_blank title='HTML Online Validation Tidy Errors Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/html-online-validation-tidy-errors-tutorial'>HTML Online Validation Tidy Errors Tutorial<\/a> efforts.<\/p>\n<p>Perhaps you&#8217;d like to try the &#8220;Usage&#8221; button of the <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/sanitizer_api_test.html_GETME\" title=\"sanitizer_api_test.html\">proof of concept <a target=_blank href=\"https:\/\/www.rjmprogramming.com.au\/HTMLCSS\/sanitizer_api_test.html\" title=\"Click picture\">web application<\/a> below &#8230;<\/p>\n<p><iframe style=\"width:100%;height:1000px;\" src=\"https:\/\/www.rjmprogramming.com.au\/HTMLCSS\/sanitizer_api_test.html\"><\/iframe><\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d56492' onclick='var dv=document.getElementById(\"d56492\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/validation\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d56492' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d63915' onclick='var dv=document.getElementById(\"d63915\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/linux\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d63915' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d63924' onclick='var dv=document.getElementById(\"d63924\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/browse\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d63924' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d63930' onclick='var dv=document.getElementById(\"d63930\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/onclick\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d63930' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Onto yesterday&#8217;s XML Lint Validation Browsing Tutorial XML Lint Validation web application progress, today, we start to add some onclick and ondblclick event logic to those left hand table cell pair of textarea elements &#8230; &lt;?php echo &#8221; function gcbr() &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/xml-lint-validation-onclick-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,14,37],"tags":[3672,1993,3531,224,4796,251,252,400,2288,3336,513,4792,4790,4791,555,557,3961,611,626,631,2032,2020,4787,1907,2287,835,861,1666,1772,2960,4789,4788,1319,1429],"class_list":["post-63930","post","type-post","status-publish","format-standard","hentry","category-elearning","category-event-driven-programming","category-tutorials","tag-broadband","tag-browse","tag-browsing","tag-colour","tag-colour-stop","tag-connect","tag-connection","tag-event","tag-fibre-to-the-node","tag-filename","tag-google","tag-google-home","tag-google-mesh","tag-google-wifi-mesh","tag-hardware-2","tag-hashtag","tag-hashtagging","tag-install","tag-ios","tag-iphone","tag-lan","tag-linear-gradient","tag-mesh","tag-modem","tag-nbn","tag-network","tag-onclick","tag-ondblclick","tag-port","tag-setup","tag-subnet","tag-subnetwork","tag-tutorial","tag-wifi"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/63930"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=63930"}],"version-history":[{"count":5,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/63930\/revisions"}],"predecessor-version":[{"id":63936,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/63930\/revisions\/63936"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=63930"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=63930"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=63930"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}