Home  >  Article  >  Backend Development  >  请问一下php处理xml的有关问题

请问一下php处理xml的有关问题

WBOY
WBOYOriginal
2016-06-13 12:09:59752browse

请教一下php处理xml的问题
如题,使用如下代码后,源文件中,会被变为:即,属性中的单引号会被变为双引号,最后/前面的空格也没了,请问如何不让它这样?


<?php<br />      $xml = simplexml_load_file('1.xml');<br />      $xml->asXML('2.xml');<br />?>

------解决思路----------------------
使用双引才是标准写法,最后/前的空格是没有意义,所以程序帮你去掉。
asXML出来的是标准的xml,不会影响使用的。

如果你不想程序帮你转,你直接写成以下就可以了。
$xml = file_get_contents('1.xml');
file_put_contents('2.xml', $xml, true);
?>

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn