0

So i'm not an PHP/XML expert but i've a simple question that i'm sure you can answer !

I'll explain :

I have a xml file which is in /requests/decoded, i need a part of it to follow my PHP script :

$accountToken =

I want him to grab these 2 parts of the XML :

<key>ActivationRandomness</key>
<string>391E262D-27A8-43AB-944F-C4F33AB12F6E</string>

<key>UniqueDeviceID</key>
<string>69348f0d170f3ef67826afa103bec669c23373cf</string>

Can you help me please ? Thanks !

EDIT :

I forgot to mention that i don't want to print something.. I just have to grab 2 string from XML to encode them after.. Here's the next part of the process :

$deviceCertificate =base64_encode($certout);
$accountToken = HERE I NEED ACTIVATIONRANDOMNESS & UNIQUEDEVICEID
$accountTokenBase64 = base64_encode($accountToken);
$pkeyid = openssl_pkey_get_private(file_get_contents("certs/private_key.pem"));
$data = $accountTokenBase64;
openssl_sign($data, $signature, $pkeyid);

My PHP have also this which i don't know how to include the data in the $accountToken :

case "ActivationRandomness": $activationRamdomess = $nodes->item($i + 1)->nodeValue; break;
case "DeviceCertRequest": $deviceCertRequest=base64_decode($nodes->item($i + 1)->nodeValue); break;
case "DeviceClass": $deviceClass=strtolower($nodes->item($i + 1)->nodeValue); break;
case "UniqueDeviceID": $uniqueDiviceID = $nodes->item($i + 1)->nodeValue; break;
WrathChild
  • 31
  • 3
  • please show us the full xml or the full path to your xml tags u want to grab – ins0 Jul 28 '14 at 07:07
  • ok please remove your comment and the pastebin link. look at the question to solve your problem http://stackoverflow.com/questions/6399504/get-attributes-and-values-using-simplexml – ins0 Jul 28 '14 at 07:42
  • I still don't understand.. :/ I guess a simplexml_load_string would be enough, but i don't know how to write it. >. – WrathChild Jul 28 '14 at 08:00

1 Answers1

1

You can use simplexml_load_file() to parse the XML in php.

Refer documentation : http://php.net/manual/en/function.simplexml-load-file.php

  • 1
    This should be a comment, not an answer as it doesn't address the question completely. – Bart Friederichs Jul 28 '14 at 07:11
  • Thanks, but i don't understand how i can do that.. I mean ; $accountToken = simplexml_load_file ( string $'.$uniqueDiviceID' [, string $ActivationRandomness]; Because my XML file is generated in this way $decodedrequest->save('requests/decoded/'.$uniqueDiviceID.'.xml') I can't even answer.. That sucks. :/ – WrathChild Jul 28 '14 at 07:19
  • Here is a stacoverflow link might help you . http://stackoverflow.com/questions/10586046/how-to-parse-xml-data-to-a-php-variable – Vikram Anand Bhushan Jul 28 '14 at 07:22