Skip to content

empty strings are coming as self closing xml element #38

@halilgithub

Description

@halilgithub

Hello,

at first thank you for that great library, I have a question: I am converting a small json object to xml but keys with empty strings values ("Value": "") in json are coming as self closing xml element (<Value />) But I want it to be a normal opening and closing xml element (<Value></Value>). What am I doing wrong ?

Code:

var myjson = { "Test_details": {
"Test_No.": {
"Value": "",
"Remark": "to be filled by me",
"Example": 1234
}}};

console.log(jsontoxml(myjson, xmlHeader=true, escape=true, removeIllegalNameCharacters=true));

Output:

<?xml version="1.0" encoding="utf-8"?>
<Test_details>
<Test_No.>
<Value />
<Remark>to be filled by me</Remark>
<Example>1234</Example>
</Test_No.>
</Test_details>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions