Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customize the serialization of an empty string for XML #538

Closed
MedAhamada opened this issue Dec 27, 2016 · 4 comments
Closed

Customize the serialization of an empty string for XML #538

MedAhamada opened this issue Dec 27, 2016 · 4 comments

Comments

@MedAhamada
Copy link

How can i customize the default serialization of an empty string attribute ? For example:

   /**
     * @XmlElement(cdata=false)
     * @var string
     */
    protected $name = '';

istead of <name /> i want <name></name> in the xml file.

@goetas
Copy link
Collaborator

goetas commented Dec 27, 2016

in xml there is no difference between <name /> i want <name></name>.

any special reason to rely on it?

currently is not supported by jms.

(see LIBXML_NOEMPTYTAG on http://php.net/manual/en/domdocument.savexml.php )

@MedAhamada
Copy link
Author

Actually i'm working on an application that requires specifically the second form and i don't know how to do that. Any idea ?

@goetas
Copy link
Collaborator

goetas commented Dec 27, 2016

$dom = new DOMDocument();
$dom->loadXML($xml);
echo $dom->saveXML(null, LIBXML_NOEMPTYTAG); 

@MedAhamada
Copy link
Author

Ok thanks @goetas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants