Skip to content

cdata property with null value generate an xml node #700

@Kelgors

Description

@Kelgors
  • Are you running the latest version?
  • Have you included sample input, output, error, and expected output?
  • Have you checked if you are using correct configuration?
  • Did you try online tool?
  • Have you checked the docs for helpful APIs and examples?

Description

During XML building, CDATA with null value is not handled properly. When a value is null, the cdata property is ignored and treated as a normal node.

Code

import { XMLBuilder } from 'fast-xml-parser'
const jObj = {
  a: { $cdata: null },
  b: { $cdata: undefined },
};
const builder = new XMLBuilder({ cdataPropName: '$cdata' });
console.log(builder.build(jObj));

Output

<a><$cdata/></a><b></b>

expected data

<a></a><b></b>

Would you like to work on this issue?

  • Yes
  • No

Bookmark this repository for further updates. Visit SoloThought to know about recent features.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions