3
$xmlFile="<test>WPUBON</test>
    <test1>SAPRTA</test1>
    <test2></test2>
    <test3></test3> ";

I have a String as above and i'm parsing this using PHP DOMDocuments

$xml = new DOMDocument("1.0", "UTF-8");
$xml->loadXML($xmlFile);
$xml->save("out/".$xmlFileName.".xml");

The output of empty tags comes as </test2> which i need to be <test2></test2> due to the application which process this xml needed as that.

Please let me know a way to do this !

4

1 に答える 1

7

のマニュアルページを確認してくださいDOMDocument::save()。オプションに対応していますLIBXML_NOEMPTYTAG。これを試して:

$xml->save("out/".$xmlFileName.".xml", LIBXML_NOEMPTYTAG );
于 2013-04-24T04:23:56.713 に答える