Archive:PHP and MySQL Programming/XML and PHP: Difference between revisions
wikademia>Quolo m added "data_" to correct function name |
wikademia>Wikademia m moved PHP and MySQL Programming/XML and PHP to Archive:PHP and MySQL Programming/XML and PHP over redirect |
||
| (17 intermediate revisions by 9 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. | 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 . | ||
Because of its wide-spread use in the IT industry, it is fitting that we as PHP developers know how to make use of XML files in our PHP applications. | Because of its wide-spread use in the IT industry, it is fitting that we as PHP developers know how to make use of XML files in our PHP applications. | ||
| Line 67: | Line 64: | ||
<? | <? | ||
xml_set_character_handler(XML_PARSER, CHARACTER_FUNCTION); | |||
?> | ?> | ||
The two arguments accepted by the | The two arguments accepted by the set_character_handler() function are : | ||
1. XML_PARSER - The variable that you created when you called the xml_parser_create() function. | 1. XML_PARSER - The variable that you created when you called the xml_parser_create() function. | ||
| Line 100: | Line 97: | ||
=== Cleaning Up === | === Cleaning Up === | ||
After parsing an XML document, it is considered good | 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 152: | Line 149: | ||
</head> | </head> | ||
<body> | <body> | ||
<h2>Google Articles</h2> | |||
<dl> | |||
<?php | <?php | ||
| Line 175: | Line 172: | ||
global $insideitem, $tag, $title, $description, $link; | global $insideitem, $tag, $title, $description, $link; | ||
if ($name == "ITEM") { | if ($name == "ITEM") { | ||
printf(" | printf("<dt><b><a href='%s'>%s</a></b></dt>", | ||
trim($link),trim($title)); | trim($link),trim($title)); | ||
printf(" | printf("<dd>%s</dd>", trim($description)); | ||
$title = ""; | $title = ""; | ||
$description = ""; | $description = ""; | ||
| Line 217: | Line 214: | ||
xml_parser_free($xml_parser); | xml_parser_free($xml_parser); | ||
?> | ?> | ||
</dl> | |||
</body> | </body> | ||
</html> | </html> | ||
== Dumping Database Contents into an XML File == | == Dumping Database Contents into an XML File == | ||
[[../Common Functions and Operators/|Previous: Common Functions and Operators]] | [[../|TOC]] | |||
[[Category:PHP and MySQL Programming|{{SUBPAGENAME}}]] | |||