Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected output for XML with certain type of comments. #423

Closed
5 of 6 tasks
VShingala opened this issue Jan 24, 2022 · 1 comment
Closed
5 of 6 tasks

Unexpected output for XML with certain type of comments. #423

VShingala opened this issue Jan 24, 2022 · 1 comment

Comments

@VShingala
Copy link

VShingala commented Jan 24, 2022

  • 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?

Description

For mentioned valid input, parser doesn't parse data correctly. As can be seen in the output, an extra node named <-- is introduced for comment.

I understand that adding space before and after comment (<!-- >> ISO DICTIONARY TYPES << -->) solves the issue but, wanted to know if there is any issue in understanding such comments by parser. Also XML is suggested valid in online tool.

Input

<xsd:element name="AccountHolderDetails">
   <xsd:complexType>
       <xsd:sequence>
            <!-->> ISO DICTIONARY TYPES <<-->
            <xsd:element minOccurs="0" name="address" nillable="true" type="Address" />
       </xsd:sequence>
   </xsd:complexType>
</xsd:element>

Code

const fastXMLParser = require('fast-xml-parser'),
  options = {
    ignoreAttributes: false,
    ignoreNameSpace: false,
    parseNodeValue: true,
    trimValues: true
  };

const parsed = fastXMLParser.parse(xmlDocument, options);

Output

{
  "xsd:element": {
    "@_name": "AccountHolderDetails",
    "xsd:complexType": {
      "xsd:sequence": {
        "#text": "> ISO DICTIONARY TYPES",
        "<--": {
          "xsd:element": {
            "@_minOccurs": "0",
            "@_name": "address",
            "@_nillable": "true",
            "@_type": "Address"
          }
        }
      }
    }
  }
}

expected data

{
  "xsd:element": {
    "@_name": "AccountHolderDetails",
    "xsd:complexType": {
      "xsd:sequence": {
        "xsd:element": {
          "@_minOccurs": "0",
          "@_name": "address",
          "@_nillable": "true",
          "@_type": "Address"
        }
      }
    }
  }
}

Would you like to work on this issue?

  • Yes
  • No
@github-actions
Copy link

I'm glad you find this repository helpful. I'll try to address your issue ASAP. You can watch the repo for new changes or star it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants