PHP Classes

Tag Names

Recommend this page to a friend!

      XML Reader  >  All threads  >  Tag Names  >  (Un) Subscribe thread alerts  
Subject:Tag Names
Summary:Display tag/element names in returned array
Messages:1
Author:Peter Redding
Date:2005-12-08 16:51:55
 

  1. Tag Names   Reply   Report abuse  
Picture of Peter Redding Peter Redding - 2005-12-08 16:51:55
Hi,

Does anyone know if it is possible for this class to return the tag names rather than element positions in the array that is returned ($return_array in the example given in the source code)?

Example :

For my XML file, this foreach will return a single element which itself is an array -
foreach ($return_array as $k=>$v) {
echo '<pre>';
print_r($v);
echo '</pre>';
}

This returns -
Array
(
[0] => Mr
[1] => Peter
[2] => Redding
)

However my XML tags for the first three tags/elements are <title>, <firstname> and <surname> so I would like the array returned to show as -

Array
(
[title] => Mr
[firstname] => Peter
[surname] => Redding
)

The class does 99% of what I need however if I could get it to return the tag/element names then it would be 100%.

Kind regards,

Pete.