[ create a new paste ] login | about

Link: http://codepad.org/XVEx5Ay4    [ raw code | output | fork ]

PHP, pasted on Jul 12:
<?php

$xml = '<?xml version="1.0"?>
                    <q:response xmlns:q="http://api-url">
                        <q:impression>
                            <q:content>
                                <html>
                                    <head>
                                        <meta name="HandheldFriendly" content="True" />
                                        <meta name="viewport" content="width=device-width, user-scalable=no" />
                                        <meta http-equiv="cleartype" content="on" />
                                    </head>
                                    <body style="margin:0px;padding:0px;">
                                        <iframe scrolling="no" src="http://some-url" width="320px" height="50px" style="border:none;"></iframe>
                                    </body>
                                </html>
                            </q:content>
                            <q:cpc>0.02</q:cpc>
                        </q:impression>
                    </q:response>';



//code continued
$dom = new DOMDocument;
// load the XML string defined above
$dom->loadXML($xml);

var_dump($dom->getElementsByTagNameNS('http://api-url', '*') ); // shows object(DOMNodeList)#3 (0) { } 


foreach ($dom->getElementsByTagNameNS('http://api-url', '*') as $element) 
{
    //this does not execute
    echo 'see - local name: ', $element->localName, ', prefix: ', $element->prefix, "\n";
}


Output:
1
2
3
4
5
6
object(DOMNodeList)#2 (0) {
}
see - local name: response, prefix: q
see - local name: impression, prefix: q
see - local name: content, prefix: q
see - local name: cpc, prefix: q


Create a new paste based on this one


Comments: