How to use xml serialized string in php?

This is my code:

$php_var = json_decode($json, 1);

$serializer=new XML_Serializer();
if($serializer->serialize($php_var))
$xml_string=htmlspecialchars("<?xml version='1.0' encoding='UTF-8' ?>".$serializer->getSerializedData());
echo $xml_string; 
$xml_obj = new DOMDocument;
@$xml_obj->loadXML($xml_string);

$urls=$xml_obj->getElementsByTagName('visibleUrl');
foreach($urls as $u)
      {
        echo $u->textContent."<br/>";
      }

Answers


Skip the XML part and use the parsed JSON structure directly.

 print_r($php_var);

Will show you the content. If you're looking for some "visibleUrl" string, then traverse the array recursively until you find it.

You might try Dynamic Array traversal in PHP


Need Your Help

how to use one model in two views

qml

i have one model for pictures and want to show them in grid view or list view (fullscreen) synchronously. if user clicks on one image in grid view i want this image to be shown in fullscreen mode (in

How to override log4j.properties during testing?

java maven-2 logging log4j

I'm trying to log all DEBUG messages to console during testing in maven. For this purpose I created a file src/test/resources/log4j.properties, which is going to override the configuration I alread...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.