I have a process.php with the following code:
[PHP]<?php
$xdoc = new DomDocument;
$xdoc->Load('1.xml' );
$test = $xdoc->save("2.xml" );
?>[/PHP]
It should load 1.xml file, and saves it as 2.xml.
Here is my 1.xml file:
and here is my 2.xml:
When I look at 2.xml, if there was a child element that had no value (<qty> and <st>) in 1.xml, it shows only as </qty> and </st> in 2.xml. The opening tag is not there. Is there anything I'm doing worng ? how can I fix this?
Thanks
[PHP]<?php
$xdoc = new DomDocument;
$xdoc->Load('1.xml' );
$test = $xdoc->save("2.xml" );
?>[/PHP]
It should load 1.xml file, and saves it as 2.xml.
Here is my 1.xml file:
Code:
<?xml version="1.0" encoding="UTF-8"?> <products> <product> <sku>10001</sku> <ti>Searchlight</ti> <qty>3</qty> <price>822.51</price> <st>1</st> </product> <product> <sku>10002</sku> <ti>Radio</ti> <qty></qty> <price>320.86</price> <st></st> </product> </products>
Code:
<?xml version="1.0" encoding="UTF-8"?> <products> <product> <sku>10001</sku> <ti>Searchlight</ti> <qty>3</qty> <price>822.51</price> <st>1</st> </product> <product> <sku>10002</sku> <ti>Radio</ti> </qty> <price>320.86</price> </st> </product> </products>
Thanks
Comment