Duplicate ?xml when rendering the document

Open
#689 3 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 4 days

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
javascript
Domain
tooling

Research direction

Start with the reproduction on the fast-xml-parser demo page and use the XML and JSON examples in the report to trace the parse-then-render flow. Verify whether the XML declaration is added both from configuration and from the parsed "?xml" node. Done means rendering the reported input produces one declaration and the result can be parsed again.

Written by the indexing model from the issue text.

Description

Hi!

I'm testing it now using this page: https://naturalintelligence.github.io/fast-xml-parser/

I noticed that if I provide XML like this:

<?xml version="1.0" encoding="utf-8"?>
<test></test>

it generates me the JSON like this:

{
    "?xml": {
        "@_version": "1.0",
        "@_encoding": "utf-8"
    },
    "test": ""
}

now when I render XML again I have ?xml node described twice:

<?xml version="1.0"?>
<?xml version="1.0" encoding="utf-8"?>
<test></test>

and if I parse such XML of course it fails.

Could you please check why? Is it a bug of the library or just the UI issue? Thanks!

Dominant language
JavaScript
Stars
3.1k
Forks
410
Avg merge
4d 15h
Merged PRs (30d)
8

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from NaturalIntelligence/fast-xml-parser

All issues in NaturalIntelligence/fast-xml-parser

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.