Jump to content

getting data from password protected xml to php please help!!!


allforone

Recommended Posts

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

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

***************

***************

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

***************

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.