xml parser in php

There is a build in function in php using which you can parse xml file to an array. I have an example created for the same, and it goes as mentioned below:

$xmlString = $raw;
$xmlParser = xml_parser_create();
xml_parse_into_struct($xmlParser, $xmlString, $values, $main);
xml_parser_free($xmlParser);

print_r(‘<pre>’);
echo “<b>Main array</b><br>”;
print_r($main);
echo “<br>”;
echo “<b>Values array</b><br>”;
print_r($values);
print_r(‘</pre>’);

Thanks,

Sachin (http://www.avidindiainc.com)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s