allforone Posted November 23, 2008 Share Posted November 23, 2008 Dear all, There is a session registered area in the web site. And there is a file such as "example.xml.asp" . I know the passswords. And i want to get the data from this file to another website to a php document. Is it possible to use username and password and get the data from that xml document to a php document.? I need your helps urgently please. Thank you so much for your helps... Hakan Link to comment https://forums.phpfreaks.com/topic/133878-getting-data-from-password-protected-xml-to-php-please-help/ Share on other sites More sharing options...
Mchl Posted November 23, 2008 Share Posted November 23, 2008 Possibly using curl extension, to login into site, and navigate to the file you need. Link to comment https://forums.phpfreaks.com/topic/133878-getting-data-from-password-protected-xml-to-php-please-help/#findComment-696949 Share on other sites More sharing options...
allforone Posted November 24, 2008 Author Share Posted November 24, 2008 Dear Mchl, Thank you very much for you kindly reply. But there is a problem. I can get the data from the normal XML structure. Here is the examples of my code; **************** <item> <urun>urunadi</urun> <uid>urunadi</uid> <adet>122</adet> </item> şeklinde olursa. <? $veri = array(); $kaynak = file_get_contents("orn.XML"); $temp = split("<item>",$kaynak); for ($i=1;$i<=count($temp);$i++){ if(trim($temp[$i])==''){continue;} preg_match('/<uid>(.*)<\/uid>/i', $temp[$i], $uid); preg_match('/<adet>(.*)<\/adet>/i', $temp[$i], $adet); array_push($veri,array($uid[1],$adet[1])); if("urunadi"==$uid[1]) echo "-<font color=red>".$adet[1]."</font><br>"; } ?> It is easy to get the data is easy and it works... *************** But i can't get the data from this structure : (i need help please.): ******************* <item> <Urun Urun_Kod="A111" Urun_Ad="urun1" Fiyat="12"/> <Urun Urun_Kod="A111" Urun_Ad="urun12" Fiyat="122"/> <Urun Urun_Kod="A111" Urun_Ad="urun13" Fiyat="123"/> </item> <? $veri = array(); $kaynak = file_get_contents("orn.XML"); $temp = split("<Urun",$kaynak); for ($i=1;$i<=count($temp);$i++){ if(trim($temp[$i])==''){continue;} split('/Urun_Kod=\"(.*)\"/i', $temp[$i], $aid); split('/Urun_Ad=\"(.*)\"/i', $temp[$i], $ad); array_push($veri,array($aid[1],$ad[1])); if("A111"==$aid[1]) echo "-<font color=red>".$ad[1]."</font><br>"; } //XML END ?> i tried like this but it didnt work... Help pls *************** Link to comment https://forums.phpfreaks.com/topic/133878-getting-data-from-password-protected-xml-to-php-please-help/#findComment-697505 Share on other sites More sharing options...
Mchl Posted November 24, 2008 Share Posted November 24, 2008 Try simplexml Link to comment https://forums.phpfreaks.com/topic/133878-getting-data-from-password-protected-xml-to-php-please-help/#findComment-697511 Share on other sites More sharing options...
allforone Posted November 24, 2008 Author Share Posted November 24, 2008 *************** THIS IS THE PROBLEM, PLEASE CAN YOU CHECK AGAIN. Because i have the problem is the following codes. i can use SimpleXML. but the problem is the followin codes. But i can't get the data from this structure : (i need help please.): ******************* <item> <Urun Urun_Kod="A111" Urun_Ad="urun1" Fiyat="12"/> <Urun Urun_Kod="A111" Urun_Ad="urun12" Fiyat="122"/> <Urun Urun_Kod="A111" Urun_Ad="urun13" Fiyat="123"/> </item> <? $veri = array(); $kaynak = file_get_contents("orn.XML"); $temp = split("<Urun",$kaynak); for ($i=1;$i<=count($temp);$i++){ if(trim($temp[$i])==''){continue;} split('/Urun_Kod=\"(.*)\"/i', $temp[$i], $aid); split('/Urun_Ad=\"(.*)\"/i', $temp[$i], $ad); array_push($veri,array($aid[1],$ad[1])); if("A111"==$aid[1]) echo "-<font color=red>".$ad[1]."</font><br>"; } //XML END ?> i tried like this but it didnt work... Help pls *************** Link to comment https://forums.phpfreaks.com/topic/133878-getting-data-from-password-protected-xml-to-php-please-help/#findComment-697560 Share on other sites More sharing options...
Mchl Posted November 24, 2008 Share Posted November 24, 2008 I understand, that you have a file like this: <item> <Urun Urun_Kod="A111" Urun_Ad="urun1" Fiyat="12"/> <Urun Urun_Kod="A111" Urun_Ad="urun12" Fiyat="122"/> <Urun Urun_Kod="A111" Urun_Ad="urun13" Fiyat="123"/> </item> So you can use script like this: if (file_exists('orn.xml')) { $xml = simplexml_load_file('orn.xml'); } if($xml) { foreach ($xml->item->children() as $item) { foreach($item->attributes() as $attribute => $value) { echo $attribute.":".$value; } } } to echo attributes of each Urun item Link to comment https://forums.phpfreaks.com/topic/133878-getting-data-from-password-protected-xml-to-php-please-help/#findComment-697577 Share on other sites More sharing options...
allforone Posted November 25, 2008 Author Share Posted November 25, 2008 Thank you so much. I have sold the problem as you show... Many thanks again. Regards... Link to comment https://forums.phpfreaks.com/topic/133878-getting-data-from-password-protected-xml-to-php-please-help/#findComment-698562 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.