Monday, January 17, 2011

Php accessing XML with NameSpace Simple Example

<?php
$xmlString="<?xml version=\"1.0\" encoding=\"UTF-8\"?>
     <ns0:Tango xmlns:ns0=\"http://some.com/schemas/Tango/1.0.0\">
    <ns0:Charlie>
        <ns0:Papi>
            <ns0:Carbon> SCANNER.TIF302.42.236</ns0:Carbon>
        <ns0:Creator>1545421</ns0:Creator>
         <ns0:Jaco>130803</ns0:Jaco>
       </ns0:Papi>
  </ns0:Charlie></ns0:Tango>";
$xml = simplexml_load_string($xmlString);
$dc = $xml->children('ns0',true)->children('ns0',true)->children('ns0',true);

//I wanted to access the value in Creator Node
echo $dc;

No comments:

Post a Comment