{"id":4008,"date":"2013-09-05T05:06:42","date_gmt":"2013-09-04T19:06:42","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=4008"},"modified":"2020-05-14T20:35:58","modified_gmt":"2020-05-14T10:35:58","slug":"php-xml-and-dtd-validate-primer-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/php-xml-and-dtd-validate-primer-tutorial\/","title":{"rendered":"PHP XML and DTD Validate Primer Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/XML\/Validate\/\"><img decoding=\"async\" style=\"float:left; border: 15px solid pink;\" alt=\"PHP XML and DTD Validate Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/XML\/Validate\/PHP_XML_DTD_Validate_Primer.jpg\" title=\"PHP XML and DTD Validate Primer Tutorial\"  \/><\/a><p class=\"wp-caption-text\">PHP XML and DTD Validate Primer Tutorial<\/p><\/div>\n<p>The XML Validation subject area is quite complex.    The reason for this is that when there is intelligence in your data, as XML often has, it can be organized in a variety of ways.   One approach with XML data is to oversee its integrity with the use of <a target=_blank title='DTD information from Wikipedia' href='http:\/\/en.wikipedia.org\/wiki\/Document_type_definition'>DTD schemas<\/a>, which is like a blueprint for your XML data, outlining how it should be structured to pass validation checks.   If you know your XML data passes the validation tests implied by the DTD then you are likely to have a very successful project, if the DTD has been structured methodically and has enough flexibility to express all the complication needed to satisfy business logic requirements.<\/p>\n<p>PHP has functionality to help with validating XML in a variety of different scenarios, as do other languages such as Python, for example.   Here for this tutorial there were two huge contributions from:<\/p>\n<ul>\n<li>the Eclipse IDE XML examples provided ( the same as used in yesterday&#8217;s tutorial <a target=_blank title='Java Eclipse XML and DTD Validate Primer Tutorial' href='http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=3993'>Java Eclipse XML and DTD Validate Primer Tutorial<\/a> )<\/li>\n<li>very good tutorials <a target=_blank title='Tutorial about validating XML against a real existing DTD' href='http:\/\/stackoverflow.com\/questions\/101935\/validate-xml-using-a-custom-dtd-in-php'>here<\/a> and <a target=_blank title='PHP lib err tutorial' href='http:\/\/php.net\/manual\/en\/function.libxml-get-errors.php'>here<\/a> about validating XML against a real existing DTD<\/li>\n<\/ul>\n<p>In this primer  <a target=_blank title='click picture' href='http:\/\/www.rjmprogramming.com.au\/PHP\/XML\/Validate\/'>tutorial<\/a> you can see some PHP XML and DTD validation program in action with a web browser.  PHP can work at the command line as well, and if you are interested, try <a target=_blank title='Command Line PHP' href='http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=262'>Are you interested in combating drudgery?<\/a><\/p>\n<p>Link to downloadable PHP programming source code for XML and DTD validation <a target=_blank title='xmldtdvalidate.php' href='http:\/\/www.rjmprogramming.com.au\/PHP\/XML\/Validate\/xmldtdvalidate.php_GETME'>xmldtdvalidate.php<\/a><\/p>\n<p>Link to sample DTD data <a target=_blank title='Invoice.dtd' href='http:\/\/www.rjmprogramming.com.au\/PHP\/XML\/Validate\/Invoice.dtd_GETME'>Invoice.dtd<\/a><\/p>\n<p>Link to sample XML data <a target=_blank title='Invoice.xml' href='http:\/\/www.rjmprogramming.com.au\/PHP\/XML\/Validate\/Invoice.xml_GETME'>Invoice.xml<\/a><\/p>\n<p>Link to live run <a target=_blank title='Invoice.xml' href='http:\/\/www.rjmprogramming.com.au\/PHP\/XML\/Validate\/index.php?inxml=http:\/\/www.rjmprogramming.com.au\/PHP\/XML\/Validate\/Invoice.xml_GETME'>here<\/a> or you can use this one to be prompted for your own data to process <a target=_blank title='Invoice.xml' href='http:\/\/www.rjmprogramming.com.au\/PHP\/XML\/Validate\/index.php'>here<\/a>.   Have heard the judge say <em>&#8220;here, here&#8221;<\/em> as well (if that is any help).<\/p>\n<p><strong><em>Did you know?<\/em><\/strong><\/p>\n<p>If you expect a ruler (kind of) HTML p tag&#8217;s contents to line up appropriately with another HTML p tag&#8217;s contents above it, you will probably not succeed with any web default font that may get applied to the HTML p tags.   Instead you need to have a font-family styling for a <a target=_blank title='monospaced font information from Wikipedia ... ta' href='http:\/\/en.wikipedia.org\/wiki\/Monospaced_font'>monospaced font<\/a>, the most famous one that springs to mind being good ol&#8217; <a target=_blank title='Courier New information at Wikipedia ... thanks' href='http:\/\/en.wikipedia.org\/wiki\/Courier_%28typeface%29'>Courier New<\/a> (which was designed for use with <a target=_blank title='typewriter information from Wikipedia' href='http:\/\/en.wikipedia.org\/wiki\/Typewriter\u200e'>typewriters<\/a> &#8230; yes, you need a link these days?! &#8230; while we&#8217;re at it, do you remember good ol&#8217; <a target=_blank title='telex information from Wikipedia ... terima kasih' href='http:\/\/en.wikipedia.org\/wiki\/Telex\u200e'>telex<\/a> or good ol&#8217; <a target=_blank title='fax information from Wikipedia ... merci' href='http:\/\/en.wikipedia.org\/wiki\/Fax\u200e'>fax<\/a>?).   A Courier New HTML p tag element could be<br \/>\n&lt;p id=&#8217;mycouriernewptag&#8217; style=&#8217;font-family: Courier, &#8220;Courier New&#8221;, monospace;&#8217;&gt;My Courier New HTML p tag element&lt;\/p&gt;<\/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='#d4008' onclick='var dv=document.getElementById(\"d4008\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"http:\/\/www.rjmprogramming.com.au\/wordpress\/?s=Python\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d4008' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>The XML Validation subject area is quite complex. The reason for this is that when there is intelligence in your data, as XML often has, it can be organized in a variety of ways. One approach with XML data is &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/php-xml-and-dtd-validate-primer-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,37],"tags":[327,368,932,997,1319,1357,1480],"class_list":["post-4008","post","type-post","status-publish","format-standard","hentry","category-elearning","category-tutorials","tag-did-you-know","tag-dtd","tag-php","tag-programming","tag-tutorial","tag-validate","tag-xml"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/4008"}],"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=4008"}],"version-history":[{"count":1,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/4008\/revisions"}],"predecessor-version":[{"id":49014,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/4008\/revisions\/49014"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=4008"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=4008"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=4008"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}