Archive:PHP and MySQL Programming/XML and PHP: Difference between revisions

wikademia>Darklama
wikademia>Wikademia
 
(7 intermediate revisions by 4 users not shown)
Line 1: Line 1:
== Introduction ==
== Introduction ==
 
{{?}}
XML (eXtensible Markup Language) is used in mainstream development. It might have started off as an attempt at a web standard, but is now used even in more traditional applications as a document standard. For example, the Open Document Format employed by Sun in their StarOffice and OpenOffice suites is based on XML pawan .
XML (eXtensible Markup Language) is used in mainstream development. It might have started off as an attempt at a web standard, but is now used even in more traditional applications as a document standard. For example, the Open Document Format employed by Sun in their StarOffice and OpenOffice suites is based on XML pawan .


Line 97: Line 97:
=== Cleaning Up ===
=== Cleaning Up ===


After parsing an XML document, it is considered good practise to free up the memory that is holding the parser. This is done by calling the xml_parser_free() function as follows :
After parsing an XML document, it is considered good practice to free up the memory that is holding the parser. This is done by calling the xml_parser_free() function as follows :


  <?
  <?
Line 149: Line 149:
  </head>
  </head>
  <body>
  <body>
  <h2>Google Articles</h2>
  &lt;h2>Google Articles&lt;/h2>
  <dl>
  &lt;dl>
  <?php  
  <?php  
   
   
Line 172: Line 172:
         global $insideitem, $tag, $title, $description, $link;
         global $insideitem, $tag, $title, $description, $link;
         if ($name == "ITEM") {
         if ($name == "ITEM") {
                 printf("<dt><b><a href='%s'>%s</a></b></dt>",
                 printf("&lt;dt>&lt;b><a href='%s'>%s</a>&lt;/b>&lt;/dt>",
                 trim($link),trim($title));
                 trim($link),trim($title));
                 printf("<dd>%s</dd>", trim($description));
                 printf("&lt;dd>%s&lt;/dd>", trim($description));
                 $title = "";
                 $title = "";
                 $description = "";
                 $description = "";
Line 214: Line 214:
  xml_parser_free($xml_parser);
  xml_parser_free($xml_parser);
  ?>
  ?>
  </dl>
  &lt;/dl>
  </body>
  </body>
  </html>
  </html>
Line 222: Line 222:
[[../Common Functions and Operators/|Previous: Common Functions and Operators]] | [[../|TOC]]
[[../Common Functions and Operators/|Previous: Common Functions and Operators]] | [[../|TOC]]


[[Category:PHP]]
[[Category:PHP and MySQL Programming|{{SUBPAGENAME}}]]
[[Category:MySQL]]