(http://php.net/xml_parser_create -- halfway down, from mmustafa posted
5-Jan-2004 @ 10:00) to parse some proprietary XML from a third party. I
know that one of the generated arrays has multiple values, but the XML
parser is showing only one. Here's the code:
$simple = file_get_contents('[URL_TO_SOURCE]');
if ($simple != '') {
$p = xml_parser_create();
xml_parse_into_struct($p, $simple, $vals, $index);
xml_parser_free($p);
$params = array();
$level = array();
foreach ($vals as $xml_elem) {
if ($xml_elem['type'] == 'open') {
if (array_key_exists('attributes',$xml_elem)) {
list($level[$xml_elem['level']],$extra) =
array_values($xml_elem['attributes']);
} else {
$level[$xml_elem['level']] = $xml_elem['tag'];
}
}
if ($xml_elem['type'] == 'complete') {
$start_level = 1;
$php_stmt = '$params';
while($start_level < $xml_elem['level']) {
$php_stmt .= '[$level['.$start_level.']]';
$start_level++;
}
$php_stmt .= '[$xml_elem[\'tag\']] = $xml_elem[\'value\'];';
eval($php_stmt);
}
}
echo "<pre>";
print_r ($params);
echo "</pre>";
----
So let's assume that in $params above, I have the array
"MULTIPLE_ITEMS" that should contain "12345" and "67890". When I
print_r, I get the following:
[MULTIPLE_ITEMS] => Array
(
[ITEM] => 67890
)
So, what happened to '12345'? How do I get it to also print?
Thanks for any assistance!
-Bob
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Community email addresses:
Post message: [email protected]
Subscribe: [EMAIL PROTECTED]
Unsubscribe: [EMAIL PROTECTED]
List owner: [EMAIL PROTECTED]
Shortcut URL to this page:
http://groups.yahoo.com/group/php-list
SPONSORED LINKS
| Php mysql | Job postings |
YAHOO! GROUPS LINKS
- Visit your group "php-list" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
