Skip to content

How to render some element as CDATA? #222

Description

@komareklukas

I have feed:

<?xml version="1.0" encoding="UTF-8"?>
<SHOP>
	<SHOPITEM id="392">
		<NAME>Andělika obrovská</NAME>
		<GUID>575c1bb4-710a-11eb-b3db-0cc47a6c9370</GUID>
		<SHORT_DESCRIPTION><![CDATA[<p>Výška sazenice cca 20 cm</p>]]></SHORT_DESCRIPTION>
	</SHOPITEM>
</SHOP>

I need to parse it and then render it.

I would like to ask your advice on how to render "SHORT_DESCRIPTION" as CDATA.

$reader = $service->getReader();
$reader->xml(file_get_contents($feedUrl));
$xml = $reader->parse();

//bdump($xml);

$writer = $service->getWriter();
$writer->openMemory();
$writer->setIndent(true);
$writer->startDocument('1.0', 'UTF-8');
$writer->namespaceMap[''] = '';
$writer->write($xml);

//bdump($writer->outputMemory());

Can you please add the code to my sample?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions