i just want one the data thats in between the message feild
Code: Select all
<?php
$xml = "";
$putdata = fopen( "php://input" , "rb" );
$dest_xml='/var/www/webupload/scribe'.date("H:i:s").".xml";
$file = fopen($dest_xml, "a", 0);
while(!feof( $putdata )) {
$_data = fread($putdata, 4096);
$_data = urldecode($_data);
$xml = $xml.$_data;
}
$xml = str_replace("response=","",$xml);
$current = "";
function start_tag($parser, $name, $attribs) {
global $current;
$current = $name;
if ($name == "MESSAGE") { }
if (is_array($attribs)) {
while(list($key,$val) = each($attribs)) {
echo strtolower($key)."=\"".$val."\"";
}
}
}
function end_tag($parser, $name) {
if ($name == "message") { }
}
function tag_contents($parser, $xml) {
global $current;
if ($current == "message") { echo $xml; }
}
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "start_tag", "end_tag");
xml_set_character_data_handler($xml_parser, "tag_contents");
if(!(xml_parse($xml_parser, $xml, TRUE))){
die("Error on line " . xml_get_current_line_number($xml_parser));
}
xml_parser_free($xml_parser);
fwrite($file, $xml);
fclose($putdata);
fclose($file);
?>
my outupt is this the only thing that is working properly is the str_replace at this point
Code: Select all
<response><external-xml></external-xml><external-id>789456123</external-id><audio-duration>15</audio-duration><trans-xml><message><![CDATA[This is a (<span style='color:blue' title='I'm naughty, are you naughty?'>smurf</span>?). Test 1, 2. Test 1, 2, 3. 1, 2, 3, 4, 5, 6, 7, 8, 9, 10. Code hear communications.]]></message><result>transcribed</result></trans-xml><metadata/><truncated>false</truncated><error-code>0</error-code><ss-id>260141855</ss-id></response>