Hi all,
I'm so glad there's a forum for the php builder.I helps me so much to solve problems in php.Anyway, i have a problem to convert XML data structure into php arays with the concept of SAX. I realized this has to be done using xml_parse_into_struct.But, I'm confused about the usage of this function.
Here is the xml document:
<?xml version="1.0"?>
<bookmarks category="News">
<link id="15696">
<title>CNN</title>
<url>http://www.cnn.com/</url>
<last_access>2000-09-08</last_access>
</link>
<link id="3763">
<title>Freshmeat</title>
<url>http://www.freshmeat.net/</url>
<last_access>2001-04-23</last_access>
</link>
<link id="84574">
<title>Slashdot</title>
<url>http://www.slashdot.com/</url>
<last_access>2001-12-30</last_access>
</link>
</bookmarks>
I want to change it into something like:
First Array
(
[0] => Array
(
[tag] => BOOKMARKS
[type] => open
[level] => 1
[attributes] => Array
(
[CATEGORY] => News
)
)
[1] => Array
(
[tag] => LINK
[type] => open
[level] => 2
[attributes] => Array
(
[ID] => 15696
)
)
And so on.
And second array should print :
Second Array
(
[BOOKMARKS] => Array
(
[0] => 0
[1] => 16
)
[LINK] => Array
(
[0] => 1
[1] => 5
[2] => 6
[3] => 10
[4] => 11
[5] => 15
)
[TITLE] => Array
(
[0] => 2
[1] => 7
[2] => 12
)
And so on.
Thus the first array prints all the elements or attributes it encounters and
second array prints the occurrence indicator and frequency of occurrence
of the elements. There is a function in php that prints an array exactly as
above,but i don't know what it is.
Could someone help me please.I really really appreciate it.
Thank you very much