Skip to content

Dynamically add conforming CDATA sections? #398

@stevenvachon

Description

@stevenvachon

Is there a way to dynamically add CDATA that conforms to type:"cdata"?

var xml = "<container> <tag1> <![CDATA[ asdf ]]> </tag1> <tag2/> </container>";
var $ = require("cheerio").load(xml, {xmlMode:true});

$("tag2").append("<![CDATA[ asdf ]]>");
$(":root").append("<tag3><![CDATA[ asdf ]]></tag3>").children("tag3");

// <container> <tag1> <![CDATA[ asdf ]]> </tag1> <tag2><!--[CDATA[ asdf ]]--></tag2> <tag3><!--[CDATA[ asdf ]]--></tag3></container>
console.log( $.xml() );

So far, all I could figure out was to manually mimic the object/array structure (annoying).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    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