Új hozzászólás Aktív témák
-
Balint133
aktív tag
válasz
Balint133
#2905
üzenetére
Wopsz lejart sajnos az idolimit...
nos koszonom az eddigi segitsegedet, sikerult mukodesre birnom fopen()-nel is
az ini_set bevalt...ime a kod aki esetleg meg hasonlo problemaba utkozott volna:
function xml2array($url, $get_attributes = 1, $priority = 'tag')
{
ini_set('user_agent',$_SERVER['HTTP_USER_AGENT']); //mozilla eseteben ez: 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.1) Gecko/20090715 Firefox/3.5.1'
$contents = "";
if (!function_exists('xml_parser_create'))
{
return array ();
}
$parser = xml_parser_create('');
if (!($fp = @ fopen($url, 'rb')))
{
return array ();
}
while (!feof($fp))
{
$contents .= fread($fp, 8192);
}
fclose($fp);
xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, "UTF-8");
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
xml_parse_into_struct($parser, trim($contents), $xml_values);
xml_parser_free($parser);
if (!$xml_values)
return; //Hmm...
$xml_array = array ();
$parents = array ();
$opened_tags = array ();
$arr = array ();
$current = & $xml_array;
$repeated_tag_index = array ();
foreach ($xml_values as $data)
{
unset ($attributes, $value);
extract($data);
$result = array ();
$attributes_data = array ();
if (isset ($value))
{
if ($priority == 'tag')
$result = $value;
else
$result['value'] = $value;
}
if (isset ($attributes) and $get_attributes)
{
foreach ($attributes as $attr => $val)
{
if ($priority == 'tag')
$attributes_data[$attr] = $val;
else
$result['attr'][$attr] = $val; //Összes attribútum elhelyezése egy tömbben aminek a neve: 'attr'
}
}
if ($type == "open")
{
$parent[$level -1] = & $current;
if (!is_array($current) or (!in_array($tag, array_keys($current))))
{
$current[$tag] = $result;
if ($attributes_data)
$current[$tag . '_attr'] = $attributes_data;
$repeated_tag_index[$tag . '_' . $level] = 1;
$current = & $current[$tag];
}
else
{
if (isset ($current[$tag][0]))
{
$current[$tag][$repeated_tag_index[$tag . '_' . $level]] = $result;
$repeated_tag_index[$tag . '_' . $level]++;
}
else
{
$current[$tag] = array (
$current[$tag],
$result
);
$repeated_tag_index[$tag . '_' . $level] = 2;
if (isset ($current[$tag . '_attr']))
{
$current[$tag]['0_attr'] = $current[$tag . '_attr'];
unset ($current[$tag . '_attr']);
}
}
$last_item_index = $repeated_tag_index[$tag . '_' . $level] - 1;
$current = & $current[$tag][$last_item_index];
}
}
elseif ($type == "complete")
{
if (!isset ($current[$tag]))
{
$current[$tag] = $result;
$repeated_tag_index[$tag . '_' . $level] = 1;
if ($priority == 'tag' and $attributes_data)
$current[$tag . '_attr'] = $attributes_data;
}
else
{
if (isset ($current[$tag][0]) and is_array($current[$tag]))
{
$current[$tag][$repeated_tag_index[$tag . '_' . $level]] = $result;
if ($priority == 'tag' and $get_attributes and $attributes_data)
{
$current[$tag][$repeated_tag_index[$tag . '_' . $level] . '_attr'] = $attributes_data;
}
$repeated_tag_index[$tag . '_' . $level]++;
}
else
{
$current[$tag] = array (
$current[$tag],
$result
);
$repeated_tag_index[$tag . '_' . $level] = 1;
if ($priority == 'tag' and $get_attributes)
{
if (isset ($current[$tag . '_attr']))
{
$current[$tag]['0_attr'] = $current[$tag . '_attr'];
unset ($current[$tag . '_attr']);
}
if ($attributes_data)
{
$current[$tag][$repeated_tag_index[$tag . '_' . $level] . '_attr'] = $attributes_data;
}
}
$repeated_tag_index[$tag . '_' . $level]++; //0 és 1 indexek
}
}
}
elseif ($type == 'close')
{
$current = & $parent[$level -1];
}
}
return ($xml_array);
}
$array = xml2array("http://eu.wowarmory.com/guild-info.xml?r=Nordrassil&gn=Solidarity");
Új hozzászólás Aktív témák
- OLED TV topic
- Youtube Android alkalmazás alternatívák reklámszűréssel / videók letöltése
- AMD Ryzen 9 / 7 / 5 9***(X) "Zen 5" (AM5)
- PlayStation 5
- Utolérte az áremelés a PlayStation 5-öt
- Samsung Galaxy Watch6 Classic - tekerd!
- Cudy routerek
- Luck Dragon: Óraátállítás
- Autós topik
- QNAP hálózati adattárolók (NAS)
- További aktív témák...
- Bomba ár! Dell Latitude 5490 - i5-8G I 8GB I 256SSD I 14" HD I HDMI I Cam I W11 I Garancia!
- Bomba ár! Lenovo X1 Yoga 1st - i5-6G I 8GB I 512SSD I 14" FHD PXCsík I HDMI I W11 I Cam I Gari
- Bomba ár! Lenovo ThinkPad T490 - i5-8G I 8GB I 256SSD I 14" FHD I HUN I Cam I W11 I Garancia!
- HP ProDesk 600 G4 USDT,Pentium Gold G5400T,8GB DDR4,256GB M2 SSD,WIN11
- Xbox One S 1TB
- Infinix Hot 12 Pro / 8/128GB / Kártyafüggetlen / 12Hó Garancia
- GAMING PC! i5-12400F / RTX 5060 / 32GB DDR5 / 512GB NVMe / 600w! BeszámítOK
- -1millió Új Lenovo 18 Legion 9 WQUXGA 440Hz U9 275HX 64GB 4TB SSD Nvidia RTX 5090 24GB 175W Garancia
- Akciós kisWorkstation! Dell Precision 3560 i7-1165G7 4.7GHz / 32GB / 512GB / Quadro T500 2GB FHD 15"
- Xiaomi Redmi Note 14 Pro + / 8/256GB / Kártyafüggetlen / 12Hó garancia
Állásajánlatok
Cég: Laptopműhely Bt.
Város: Budapest
az ini_set bevalt...