Tag Archives: Functions

xml_parse()

It parses an XML document

Example

<?php
$xmlparser = xml_parser_create();
$fp = fopen(‘test.xml’, ‘r’);
while ($xmldata = fread($fp, 4096)){
if (!xml_parse($xmlparser,$xmldata,feof($fp)))
echo xml_error_string(xml_get_error_code($xmlparser));
}
xml_parser_free($xmlparser);
?>

xml_parse_into_struct()

It parses XML data into an array structure

Example

<?php
$xmlfile = ‘book.xml’;
$xmlparser = xml_parser_create();
$fp = fopen($xmlfile, ‘r’);
$xmldata = fread($fp, 4096);
xml_parse_into_struct($xmlparser,$xmldata,$values);
xml_parser_free($xmlparser);
echo “<pre>”;print_r($values);
?>

xml_get_error_code()

It returns XML parser error code

Example

<?php

$xmlparser = xml_parser_create();

$fp = fopen(‘test.xml’, ‘r’);

while ($xmldata = fread($fp, 4096)){

 if (!xml_parse($xmlparser,$xmldata,feof($fp)))

echo xml_error_string(xml_get_error_code($xmlparser));

}

xml_parser_free($xmlparser);

?>

xml_error_string()

It returns an error string from the XML parser

Example

<?php

$xmlparser = xml_parser_create();

$fp = fopen(‘test.xml’, ‘r’);

while ($xmldata = fread($fp, 4096)){

 if (!xml_parse($xmlparser,$xmldata,feof($fp)))

echo xml_error_string(xml_get_error_code($xmlparser));

}

print_r($xmldata);

xml_parser_free($xmlparser);

?>

ftp_systype()

It  returns the system type identifier of the remote FTP server

Example

<?php

$ftpId = ftp_connect(‘ftp.phpcodez.com’);

$login = ftp_login($ftpId, ‘anonymous’, ‘user@phpcodez.com’);

echo $type = ftp_systype($ftp) or die(“Failed”);

ftp_quit($ftpId);

?>