I'm extracting a list of items from an XML document using PHP. The desired
items are the attributes of different occurances of a specific element
within the document; the code will not need a callback for character data or
for closing tags.
$list = new Array();
function start_tag($p_id, $element, $attribs)
{
global $list;
if ($element = 'building')
$list[] = $attribs['address'];
return true;
}
//.. snip .. snip ..
xml_set_element_handler($parser, 'start_tag', create_function ('',''));
//.. snip .. snip ..
Two questions:
1. create_function ('',''); works just fine, but I was wondering if there
was a proper way to declare a void anonymous function?
2. If I were to place the parser related code within it's own function to
increase readability of the script, how would start_tag be rewritten as an
inline anonymous function? I've tried several ideas but I'm not sure how to
handle $location and it's change in scope.
Thanks in advance,
-Tim
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php