Opened 9 years ago

Last modified 4 years ago

#8566 new Feature Requests

Enable writing of CDATA

Reported by: Wolf A. Heidrich <wolf.heidrich@…> Owned by: Sebastian Redl
Milestone: To Be Determined Component: property_tree
Version: Severity: Problem
Keywords: Cc:

Description

If one tries to write a node using write_xml

<example><![CDATA[<>]]></example>

the characters <> (and probably & etc.) get escaped in HTML style. The output file will contain

<example>&lt;![CDATA[&lt;&gt;]]&gt;</example>

Might it be a solution to introduce another sub-key <xmlcdata> (like <xmlcomment>) and write code analogue to function write_xml_comment like

    template<class Ch>
    void write_xml_xcdata(std::basic_ostream<Ch> &stream,
                           const std::basic_string<Ch> &s, 
                           int indent,
                           bool separate_line,
                           const xml_writer_settings<Ch> & settings
                           )
    {
        typedef typename std::basic_string<Ch> Str;
        if (separate_line)
            write_xml_indent(stream,indent,settings);
        stream << Ch('<') << Ch('!') << Ch('[') << Ch('C') << Ch('D') << Ch('A') << Ch('T') << Ch('A') << Ch('[');
        stream << s;
        stream << Ch(']') << Ch(']') << Ch('>');
        if (separate_line)
            stream << Ch('\n');
    }

Change History (2)

comment:1 by anonymous, 5 years ago

Ого. 4 года прошло

comment:2 by anonymous, 4 years ago

Уже 5 ))

Note: See TracTickets for help on using tickets.