Skip to content

Skip an element during Xml deserialization process #229

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

Closed
jeserkin opened this issue Feb 10, 2014 · 2 comments
Closed

Skip an element during Xml deserialization process #229

jeserkin opened this issue Feb 10, 2014 · 2 comments

Comments

@jeserkin
Copy link
Contributor

I have a part of XML as follows:

<results xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/" for="XXX">
    <opensearch:Query role="request" searchTerms="XXX" startPage="1"/>
    <opensearch:totalResults>2</opensearch:totalResults>
    <opensearch:startIndex>0</opensearch:startIndex>
    <opensearch:itemsPerPage>50</opensearch:itemsPerPage>
    <albummatches>
        <album>

Is it possible to skip albummatches element and set something like?

    /**
     * @JMS\Type("array<XXX>")
     * @JMS\XmlList(inline=true, entry="albummatches\album")
     * @var XXX[]
     */
    protected $items;

Or I must implement additional class for albummatches to have something like:

class Results
{
    /**
     * @JMS\Type("array<\AlbumCollection>")
     */
    private $albummatches;

    /**
     * @return \AlbumCollection
     */
    public function getAlbummatches()
    {
        return $this->albummatches;
    }
}

/**
 * @JMS\XmlRoot("album")
 */
class AlbumCollection extends ArrayCollection
{
    /**
     * @JMS\Type("array<\Album>")
     * @JMS\XmlList(inline=true, entry="album")
     * @var \Album[]
     */
    protected $items;
}

class Album
{
    // ...
}
@jeserkin
Copy link
Contributor Author

Anyway to do that? Or the medium class is still needed for correct work?

@goetas
Copy link
Collaborator

goetas commented Aug 21, 2016

sorry for the long feedback loop.
the answer for your question is to use inline=false

@goetas goetas closed this as completed Aug 21, 2016
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