PeterPopper Posted March 31, 2010 Share Posted March 31, 2010 $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. Quote Link to comment https://forums.phpfreaks.com/topic/197065-simply-want-to-parse-a-variable-that-has-xml-but-headaches/ Share on other sites More sharing options...
teamatomic Posted March 31, 2010 Share Posted March 31, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/197065-simply-want-to-parse-a-variable-that-has-xml-but-headaches/#findComment-1034471 Share on other sites More sharing options...
PeterPopper Posted March 31, 2010 Author Share Posted March 31, 2010 teamatomic, thanks for the reply. Is part of your code missing? I only see the SimpleXMLElement Object array output, I am not sure how you get that. Quote Link to comment https://forums.phpfreaks.com/topic/197065-simply-want-to-parse-a-variable-that-has-xml-but-headaches/#findComment-1034535 Share on other sites More sharing options...
PeterPopper Posted March 31, 2010 Author Share Posted March 31, 2010 Thanks, teamatomic, your suggestion did work, I had to take a second look. Quote Link to comment https://forums.phpfreaks.com/topic/197065-simply-want-to-parse-a-variable-that-has-xml-but-headaches/#findComment-1034812 Share on other sites More sharing options...
teamatomic Posted March 31, 2010 Share Posted March 31, 2010 echo '<pre>'; print_r($cleanData); HTH Teamatomic Quote Link to comment https://forums.phpfreaks.com/topic/197065-simply-want-to-parse-a-variable-that-has-xml-but-headaches/#findComment-1034822 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.