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

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

Open
vpashovski opened this issue Sep 24, 2020 · 0 comments
Open

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

vpashovski opened this issue Sep 24, 2020 · 0 comments

Comments

@vpashovski
Copy link

vpashovski commented Sep 24, 2020

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.

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

No branches or pull requests

2 participants