-4

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/>";
      }
3
  • 4
    Stack overflow is about asking and answering questions, not posting random snippets of code. How often I see these kinds of posts is maddeningly frustrating. Commented Dec 3, 2010 at 17:58
  • Yes, this looks pretty useless. You'll need to explain what you are trying to accomplish. Why don't you access the array data directly? Commented Dec 3, 2010 at 18:05
  • just to ensure i didnot over-edit...roll-back Commented Dec 3, 2010 at 18:21

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.