5. Simple XML document 1 <?xml version = "1.0" ?> 2 3 <!-- simple.xml --> 4 <!-- Simple XML document --> 5 6 <book title = “C++ How to Program" edition = "3" > 7 8 <sample> 9 <![CDATA[ 10 11 // C++ comment 12 if ( this->getX() < 5 && value[ 0 ] != 3 ) 13 cerr << this->displayError(); 14 ]]> 15 </sample> 16 17 C++ How to Program by Deitel & Deitel 18 </book> Root node Comment nodes Attribute nodes Element nodes Text nodes
6. XPath tree for simple.xml Attribute Title C++ How to Program Element book Comment Fig. 11.1 : simple.xml Comment Simple XML document Attribute edition 3 Root Text C++ How to Program by Deitel & Deitel Element sample Text // C++ comment if (this -> getX() < 5 && value[ 0 ] != 3 ) cerr << this->displayError();
7. XML document with processing-instruction and namespace nodes 1 <?xml version = "1.0" ?> 2 3 <!-- Fig. 11.3 : simple2.xml --> 4 <!-- Processing instructions and namespacess --> 5 6 <html xmlns = "http://www.w3.org/TR/REC-html40" > 7 8 <head> 9 <title> Processing Instruction and Namespace Nodes </title> 10 </head> 11 12 <?deitelprocessor example = "fig11_03.xml" ?> 13 14 <body> 15 16 <deitel:book deitel:edition = "1" 17 xmlns:deitel = "http://www.deitel.com/xmlhtp1" > 18 <deitel:title> XML How to Program </deitel:title> 19 </deitel:book> 20 21 </body> 22 23 </html> Root node Comment nodes Namespace nodes Processing instruction node Element nodes Text nodes Attribute nodes
8. Tree diagram of an XML document with a processing-instruction node Continued on next slide ... Root Comment Fig. 11.3 : simple2.xml Comment Processing instructions and namespaces Element html Namespace http://www.w3.org/TR/REC-html40 Element head Text Processing instructions and Namespcae Nodes Element title
9. Tree diagram of an XML document with a processing-instruction node Continued from previous slide Processing Instruction deitelprocessor example = " fig11_03.xml " Element body Element book Attribute edition 1 Namespace http://www.deitel.com/xmlhtp1 Element title Text XML How to Program