PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
Copy Clear
Copy Format Clear
<?php $xml = <<<XML <?xml version="1.0" encoding="UTF-8"?> <offers> <offer> <sku><![CDATA[DQ8616433]]></sku> <name><![CDATA[Regata Nike Brasil Standard Issue Masculina]]></name> <price>332.49</price> <link><![CDATA[https://google.com]]></link> <thumbnail><![CDATA[https://imgnike-a.akamaihd.net/1300x1300/02384015.jpg]]></thumbnail> <description><![CDATA[null]]></description> <installment><![CDATA[]]></installment> </offer> <offer> <sku><![CDATA[DQ3828900]]></sku> <name><![CDATA[Tênis Nike LeBron 20 Masculino]]></name> <price>1234.99</price> <link><![CDATA[https://microsoft.com]]></link> <thumbnail><![CDATA[https://imgnike-a.akamaihd.net/1300x1300/025275CT.jpg]]></thumbnail> <description><![CDATA[null]]></description> <installment><![CDATA[]]></installment> </offer> </offers> XML; //$offers = new SimpleXMLElement($xml); $offers = simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA | LIBXML_NOBLANKS); print_r($offers); echo "\n\n"; //if (isset($offers->offer)) { if (property_exists($offers, 'offer')) { foreach ($offers->offer as $offer_item) { echo "{$offer_item->name}\n"; } }
Show:  
Copy Clear