Skip to content

Atom Feed can’t read Entry content if type is application/xml #23

Open
@vpashovski

Description

@vpashovski

Feature Request

Q A
New Feature yes

Summary

I’m trying to get content of Atom Entry where content is with type="application/xml"

In documentation https://validator.w3.org/feed/docs/atom.html#contentElement
content can have type attribute ends in +xml or /xml , then an xml document of this type is contained inline.

I have this xml:

<entry>
    <content type="application/xml">
        <m:properties>
            <d:Code>10</d:Code>
            <d:shopCode/>
            <d:Description>Some description here</d:Description>
        </m:properties>
    </content>
</entry>

When we use \Laminas\Feed\Reader\Extension\Atom\Entry::getContent method we get empty string.
I’m expecting to get an array with keys and values.

In the code

public function getContent()
{
if (array_key_exists('content', $this->data)) {
return $this->data['content'];
}
$content = null;
$el = $this->getXpath()->query($this->getXpathPrefix() . '/atom:content');
if ($el->length > 0) {
$el = $el->item(0);
$type = $el->getAttribute('type');
switch ($type) {
case '':
case 'text':
case 'text/plain':
case 'html':
case 'text/html':
$content = $el->nodeValue;
break;
case 'xhtml':
$this->getXpath()->registerNamespace('xhtml', 'http://www.w3.org/1999/xhtml');
$xhtml = $this->getXpath()
->query($this->getXpathPrefix() . '/atom:content/xhtml:div')
->item(0);
$d = new DOMDocument('1.0', $this->getEncoding());
$deep = version_compare(PHP_VERSION, '7', 'ge') ? 1 : true;
$xhtmls = $d->importNode($xhtml, $deep);
$d->appendChild($xhtmls);
$content = $this->collectXhtml(
$d->saveXML(),
$d->lookupPrefix('http://www.w3.org/1999/xhtml')
);
break;
}
}
if (! $content) {
$content = $this->getDescription();
}
$this->data['content'] = trim($content);
return $this->data['content'];
}
we can see there is no case for this.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions