Tuesday, 25 November 2014

Run PHP function on node values and then output the XML?



I have an XML that im getting from file_get_contents. It contains a bunch of values including encrypted ones which are inside <strStringValue>. I have a function that will decrypt them, i tried to use this code but it just printed out the values inside strStringValue:



<?php
if (!isset($HTTP_RAW_POST_DATA)) {
$HTTP_RAW_POST_DATA = file_get_contents("php://input");
$doc = new DOMDocument();
$doc->loadXML($HTTP_RAW_POST_DATA);
$stringvalue = $doc->getElementsByTagName('strStringValue');
foreach ($stringvalue as $strstringvalue) {
echo $strstringvalue->nodeValue, PHP_EOL;
}

include("Decrypt1.php");
$in = "$strstringvalue";

$HTTP_RAW_POST_DATA2=Decrypt1($in);
echo("$HTTP_RAW_POST_DATA2");
}
?>


Here is an example of what the XML looks like:


Encrypted



<string>
<Id>1</Id>
<strStringCaption>file-commision</strStringCaption>
<strStringValue enc="0">2734sad87asd78asdt8a7d6874slwe9832t</strStringValue>
</string>
<string>
<Id>2</Id>
<strStringCaption>file-shop</strStringCaption>
<strStringValue enc="0">78sd7asgd87adg87g873g78dad</strStringValue>
</string>


Decrypted



<string>
<Id>1</Id>
<strStringCaption>file-commision</strStringCaption>
<strStringValue enc="0">commisions.txt</strStringValue>
</string>
<string>
<Id>2</Id>
<strStringCaption>file-shop</strStringCaption>
<strStringValue enc="0">shoplist.xml</strStringValue>
</string>
<string>
<string>

No comments:

Post a Comment