Hey again me with a problem lol,
i need to get an xml file with curl and parse it ... okay so far it all works my problem now is i have no idea on how to parse it properly atm it looks like this
Now I dont know how to parse it so i can use the strings seperatly
like
etc
------
why do i need to use xml and curl? sc_trans 2 has an api which outputs results as xml funny thing is it needs to be a POST so i am using curl and theres no other way around it.
---Edit---
Thats what i use at the moment to extract the xml and its working with one part of the XML but not multiple like in the array above
i need to get an xml file with curl and parse it ... okay so far it all works my problem now is i have no idea on how to parse it properly atm it looks like this
Code:
Array ( [0] => Array ( [name] => user [pass] => test [priority] => 4 ) [1] => Array ( [name] => user [pass] => test [priority] => 4 ) [2] => Array ( [name] => user [pass] => test [priority] => 4 ) )
like
PHP Code:
echo "$user";
------
why do i need to use xml and curl? sc_trans 2 has an api which outputs results as xml funny thing is it needs to be a POST so i am using curl and theres no other way around it.
---Edit---
PHP Code:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://user:pass@domain.com:5555/api');
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, 'op=getstatus&seq=45');
curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$xml = curl_exec($ch);
function ExtractString($str, $start, $end)
{
$str_low = strtolower($str);
$pos_start = strpos($str_low, $start);
$pos_end = strpos($str_low, $end, ($pos_start + strlen($start)));
if ( ($pos_start !== false) && ($pos_end !== false) )
{
$pos1 = $pos_start + strlen($start);
$pos2 = $pos_end - $pos1;
return substr($str, $pos1, $pos2);
}
}
$match = ExtractString($xml, '<name>', '</name>');
Comment