You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
It's sometimes important to get only the XML body without the processing instructions (like the <?xml version="1.0" ?> on the top of your XML doc). At the moment, it's possible to ignore them while decoding, but not while encoding.
We follow the robustness principle "Be conservative in what you send, be liberal in what you accept", so while it's ok to ignore XML_PI_NODE by default when decoding, it must be generated by default when encoding.
…encoding (maidmaid)
This PR was merged into the 4.2-dev branch.
Discussion
----------
[Serializer] XmlEncoder doesn't ignore PI nodes while encoding
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| New feature? | yes
| BC breaks? | no
| Deprecations? | no
| Tests pass? | no
| Fixed tickets | /
| License | MIT
| Doc PR | /
It's sometimes important to get only the XML body without the processing instructions (like the `<?xml version="1.0" ?>` on the top of your XML doc). At the moment, it's possible to ignore them while decoding, but not while encoding.
```php
$encoder = new XmlEncoder('response', null, $ignoredNodeTypes = [XML_PI_NODE]);
echo $encoder->encode([], 'xml');
```
```
Expected:
<response/>
Actual:
<?xml version="1.0"?>
<response/>
```
So, a new `$encoderIgnoredNodeTypes` arg is added to the constructor which will be:
```php
public function __construct(string $rootNodeName = 'response', int $loadOptions = null, array $decoderIgnoredNodeTypes = array(XML_PI_NODE, XML_COMMENT_NODE), array $encoderIgnoredNodeTypes = array())
```
Commits
-------
2223fcc Allow to ignore PI while encoding
…redNodeTypes arg in XmlEncoder contrustor (maidmaid)
This PR was merged into the 4.2-dev branch.
Discussion
----------
[Serializer] Update changelog about the new $encoderIgnoredNodeTypes arg in XmlEncoder contrustor
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #27926
| License | MIT
| Doc PR | /
Commits
-------
49f3bfc Update changelog
…ML encoding (maidmaid)
This PR was merged into the 4.2-dev branch.
Discussion
----------
[Serializer] Add support for ignoring comments while XML encoding
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| New feature? | yes
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | /
| License | MIT
| Doc PR | /
In addition to #27926 which allowed to ignore XML processing instructions, this PR allows to ignore the XML comments while encoding.
Commits
-------
8f8230a Add support for ignoring comments while XML encoding
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
It's sometimes important to get only the XML body without the processing instructions (like the
<?xml version="1.0" ?>on the top of your XML doc). At the moment, it's possible to ignore them while decoding, but not while encoding.So, a new
$encoderIgnoredNodeTypesarg is added to the constructor which will be: