PHP DOM和单引号 [英] PHP DOM and single quotes
问题描述
有没有办法告诉DOMDocument使用单引号而不是属性的双引号?
Is there any way to tell DOMDocument to use single quotes instead of double quotes for attributes?
推荐答案
不。 DOMDocument是XML的面向数据的访问API。
No. DOMDocument is a data-oriented access API for XML. And it serializes the documents however it wants to.
没有-> save()标志 http://www.php.net/manual/en/libxml.constants.php 即可完成此操作。其他语言绑定也不允许这样做:可以nokogiri在保存xml时对属性使用单引号吗?
这是因为libxml本身并没有提供重写此方法的方法。 libxml2 / xmlsave.h
和其他没有提到引号样式的标志。所以,我怕你真的很走运。
There is no ->save() flag http://www.php.net/manual/en/libxml.constants.php in PHP to accomplish it. And other language bindings don't allow it either: Can nokogiri use single quotes for attributes on saving xml?
And this is because libxml itself does provide no means to override this. libxml2/xmlsave.h
and others mention no quote-style flags. So, I'm afraid you're really out of luck.
这篇关于PHP DOM和单引号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!