<?php
include 'xml_converter.class.php'; /* Download class file */
include 'xml.class.php'; /* Download class file */
/* Your array of data */
$data = array(
'first_name' => 'Pritom',
'middle_name' => "Kumar",
'last_name' => 'Mondal',
'url' => 'http://pritomkumar.blogspot.com',
'languages' => array(
'php language !! ' => '<!CDATA[&Php&]]>%♣♠♥♦◊〉〈 ⌋ ⌊ ⌈ ⌉ ⋮ ⋅ ⊥ ⊗ ⊕ ⊇',
'Java Script ⊆ ⊄ ⊃ ⊂ ≥ ≤ ≡ ≠ ≈ ≅ ∼ ∴ ∫ ∪ ∩ ∨',
'Java ∧ ∠ ∞ ∝ √ ∗ − ∑ ∏ ∋ ∉ ∈ ∇ ∅ ∃ ∂ ∀ ⇔ ⇓ ⇒ ⇑ ⇐',
'CSS',
"CakePhp<Help]>]]\/\/\/\/\/\/",
"jQuery"
),
'title' => 'Pritom Kumar (Web Developer)',
"inline_tag" => "<name><first>Pritom</first><last>Kumar</last></name>",
'favorite_blogs' => array(
'CSSTricks' => 'http://css-tricks.com',
'AJAXian' => 'http://ajaxian.com'
),
"invalid characters" => array(
"''" => "00-&*",
"'" => "'",
">" => ">",
"<" => "<",
"&" => "&",
"-" => "-",
"°" => "°"
)
);
/* Array to xml converting... */
$xmlConverter = new XmlConverter($data);
$xmlString = $xmlConverter->toXmlString();
/* Xml would look like this: */
echo $xmlString;
<?xml version="1.0" encoding="UTF-8"?>
<data>
<first_name><![CDATA[Pritom]]></first_name>
<middle_name><![CDATA[Kumar]]></middle_name>
<last_name><![CDATA[Mondal]]></last_name>
<url><![CDATA[http://pritomkumar.blogspot.com]]></url>
<languages>
<php_language____><![CDATA[<!CDATA[&Php&]]>%♣♠♥♦◊⟩⟨ ⌋ ⌊ ⌈ ⌉ ⋮ ⋅ ⊥ ⊗ ⊕ ⊇]]></php_language____>
<tag_0><![CDATA[Java Script ⊆ ⊄ ⊃ ⊂ ≥ ≤ ≡ ≠ ≈ ≅ ∼ ∴ ∫ ∪ ∩ ∨]]></tag_0>
<tag_1><![CDATA[Java ∧ ∠ ∞ ∝ √ ∗ − ∑ ∏ ∋ ∉ ∈ ∇ ∅ ∃ ∂ ∀ ⇔ ⇓ ⇒ ⇑ ⇐]]></tag_1>
<tag_2><![CDATA[CSS]]></tag_2>
<tag_3><![CDATA[CakePhp<Help]>]]\/\/\/\/\/\/]]></tag_3>
<tag_4><![CDATA[jQuery]]></tag_4>
</languages>
<title><![CDATA[Pritom Kumar (Web Developer)]]></title>
<inline_tag><![CDATA[<name><first>Pritom</first><last>Kumar</last></name>]]></inline_tag>
<favorite_blogs>
<CSSTricks><![CDATA[http://css-tricks.com]]></CSSTricks>
<AJAXian><![CDATA[http://ajaxian.com]]></AJAXian>
</favorite_blogs>
<invalid_characters>
<tag___><![CDATA[00-&*]]></tag___>
<tag__><![CDATA[']]></tag__>
<tag__><![CDATA[>]]></tag__>
<tag__><![CDATA[<]]></tag__>
<tag__><![CDATA[&]]></tag__>
<tag__><![CDATA[-]]></tag__>
<tag___><![CDATA[°]]></tag___>
</invalid_characters>
</data>
/* After parse xml, array would look like this: */
$xmlParser = new XmlToArrayParser($xmlString);
print_r($xmlParser);
xmlToArrayParser Object
(
[array] => Array
(
[data] => Array
(
[first_name] => Pritom
[middle_name] => Kumar
[last_name] => Mondal
[url] => http://pritomkumar.blogspot.com
[languages] => Array
(
[php_language____] => <!CDATA[&Php&]]>%♣♠♥♦◊〉〈 ⌋ ⌊ ⌈ ⌉ ⋮ ⋅ ⊥ ⊗ ⊕ ⊇
[tag_0] => Java Script ⊆ ⊄ ⊃ ⊂ ≥ ≤ ≡ ≠ ≈ ≅ ∼ ∴ ∫ ∪ ∩ ∨
[tag_1] => Java ∧ ∠ ∞ ∝ √ ∗ − ∑ ∏ ∋ ∉ ∈ ∇ ∅ ∃ ∂ ∀ ⇔ ⇓ ⇒ ⇑ ⇐
[tag_2] => CSS
[tag_3] => CakePhp<Help]>]]\/\/\/\/\/\/
[tag_4] => jQuery
)
[title] => Pritom Kumar (Web Developer)
[inline_tag] => <name><first>Pritom</first><last>Kumar</last></name>
[favorite_blogs] => Array
(
[CSSTricks] => http://css-tricks.com
[AJAXian] => http://ajaxian.com
)
[invalid_characters] => Array
(
[tag___] => Array
(
[0] => 00-&*
[1] => °
)
[tag__] => Array
(
[0] => '
[1] => >
[2] => <
[3] => &
[4] => -
)
)
)
)
[parse_error] =>
[parser:xmlToArrayParser:private] => Resource id #4
[pointer:xmlToArrayParser:private] => Array
(
[data] => Array
(
[first_name] => Pritom
[middle_name] => Kumar
[last_name] => Mondal
[url] => http://pritomkumar.blogspot.com
[languages] => Array
(
[php_language____] => <!CDATA[&Php&]]>%♣♠♥♦◊〉〈 ⌋ ⌊ ⌈ ⌉ ⋮ ⋅ ⊥ ⊗ ⊕ ⊇
[tag_0] => Java Script ⊆ ⊄ ⊃ ⊂ ≥ ≤ ≡ ≠ ≈ ≅ ∼ ∴ ∫ ∪ ∩ ∨
[tag_1] => Java ∧ ∠ ∞ ∝ √ ∗ − ∑ ∏ ∋ ∉ ∈ ∇ ∅ ∃ ∂ ∀ ⇔ ⇓ ⇒ ⇑ ⇐
[tag_2] => CSS
[tag_3] => CakePhp<Help]>]]\/\/\/\/\/\/
[tag_4] => jQuery
)
[title] => Pritom Kumar (Web Developer)
[inline_tag] => <name><first>Pritom</first><last>Kumar</last></name>
[favorite_blogs] => Array
(
[CSSTricks] => http://css-tricks.com
[AJAXian] => http://ajaxian.com
)
[invalid_characters] => Array
(
[tag___] => Array
(
[0] => 00-&*
[1] => °
)
[tag__] => Array
(
[0] => '
[1] => >
[2] => <
[3] => &
[4] => -
)
)
)
)
)
?>