Showing posts with label XML. Show all posts
Showing posts with label XML. Show all posts

XML: Simple internal DTD definition example

Best way to validate is using any browser. Open the XML file in any browser.
Also, if you open in Eclipse, you can right click on the .xml file and select "validate".

 <?xml version="1.0"?>  
 <!DOCTYPE notes [  
  <!ELEMENT notes  (note*)>  
  <!ELEMENT note  (to,from,heading,body*)>  
  <!ELEMENT to   (#PCDATA)>  
  <!ELEMENT from  (#PCDATA)>  
  <!ELEMENT heading (#PCDATA)>  
  <!ELEMENT body  (#PCDATA)>  
 ]>  
 <notes>  
      <note>  
           <to>Joe</to>  
           <from>Tom</from>  
           <heading>Hello</heading>  
      </note>  
      <note>  
           <to>Bob</to>  
           <from>Joe</from>  
           <heading>Reminder</heading>  
           <body>this is msg</body>  
      </note>  
 </notes>  

Python contextlib for Timing Python code

If you've ever found yourself needing to measure the execution time of specific portions of your Python code, the `contextlib` module o...