Jump to content

Simply want to parse a variable that has XML, but headaches


PeterPopper

Recommended Posts

$xmlVarMessyData = '<string xmlns="http://www.yahoo.org/"><endResult><ReturnCodes><Initial>Y</Initial><ShowSize>555</ShowSize><InstanNot/><UniqueId>c8e48dc3f2a1</UniqueId><MainNum>3f18e20016d</MainNum></ReturnCodes></endResult></string>';

$xmlVarMessyData = str_replace('<', '<', $xmlVarMessyData);
$xmlVarMessyData = str_replace('>', '>', $xmlVarMessyData);

$cleanData = simplexml_load_string ($xmlVarMessyData);
echo "Clean Response ShowSize element: " . $cleanData->endResult->ShowSize;

 

The code above is not echoing the 'ShowSize' element, I am getting a empty string. Thanks.

SimpleXMLElement Object
(
    [endResult] => SimpleXMLElement Object
        (
            [ReturnCodes] => SimpleXMLElement Object
                (
                    [initial] => Y
                    [showSize] => 555
                    [instanNot] => SimpleXMLElement Object
                        (
                        )

                    [uniqueId] => c8e48dc3f2a1
                    [MainNum] => 3f18e20016d
                )

        )

)
Clean Response ShowSize element: 555

$cleanData->endResult->ReturnCodes->ShowSize

 

 

HTH

Teamatomic

 

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.