Convert SimpleXMLElement object to XML format in php -


one xml file view.xml

convert simplexmlelement object after parent node it's child object need convert in xml format in php

**

view.xml 

**

> <cards name="country-cards" model="core_country" title="country" > >         <field name="name" /> >         <field name="code" /> >         <template><![cdata[ >           <div class="span12"><strong>{{name}}</strong></div>             <div> >             <div class="span8"> >               <span>{{name}}<br/> >               {{code}}<br/></span> >             </div></div>]]> >         </template> >     </cards>  **$xml = simplexml_load_file($xmlviewfilepath);** 

foreach ($xml $key=>$value) {

$value want convert in xml formate

}

question: other simple way achieve simplexmlelement object xml parsing , store database without i/o operation?

already used php conversion mechanism results in output null in database link below

http://us2.php.net/manual/en/simplexmlelement.asxml.php

try somthing this..

 $doc = new domdocument();     $doc->formatoutput = true;     $doc->loadxml($sxml->asxml());     $xml = $doc->savexml(); 

for more information check link

http://us2.php.net/manual/en/simplexmlelement.asxml.php


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -