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

ignoreAttributes breaks unpairedTags #540

Closed
5 of 6 tasks
croghostrider opened this issue Feb 1, 2023 · 1 comment
Closed
5 of 6 tasks

ignoreAttributes breaks unpairedTags #540

croghostrider opened this issue Feb 1, 2023 · 1 comment
Labels

Comments

@croghostrider
Copy link

  • 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

Hi @amitguptagwl,
i found the problem with the unpairedTags parameter.
If i set ignoreAttributes to false the paramter unpairedTags is ignored.

Input

Code

const { XMLParser, XMLBuilder } = require('fast-xml-parser')
const xmlData = `
<CommunicationLog xmlns="http://knx.org/xml/telegrams/01">
 <Telegram Timestamp="2023-01-29T23:01:06.239Z" RawData="0640103020080ee"/>
 <Telegram Timestamp="2023-01-29T23:01:16.945Z" RawData="0640103020080aa"/>
 <Telegram Timestamp="2023-01-30T22:58:27.572Z" RawData="066040c02008067"/>
 <Telegram Timestamp="2023-01-30T22:58:27.606Z" RawData="066043402008067"/>
</CommunicationLog>`

const options = {
  format: true,
  ignoreAttributes: false,
  suppressUnpairedNode: false,
  unpairedTags: ['Telegram']
}
const parser = new XMLParser(options)
const result = parser.parse(xmlData)

const builder = new XMLBuilder(options)
const output = builder.build(result)
console.log(output)

Output

<CommunicationLog xmlns="http://knx.org/xml/telegrams/01">
  <Telegram Timestamp="2023-01-29T23:01:06.239Z" RawData="0640103020080ee"></Telegram>
  <Telegram Timestamp="2023-01-29T23:01:16.945Z" RawData="0640103020080aa"></Telegram>
  <Telegram Timestamp="2023-01-30T22:58:27.572Z" RawData="066040c02008067"></Telegram>
  <Telegram Timestamp="2023-01-30T22:58:27.606Z" RawData="066043402008067"></Telegram>
</CommunicationLog>

expected data

<CommunicationLog xmlns="http://knx.org/xml/telegrams/01">
 <Telegram Timestamp="2023-01-29T23:01:06.239Z" RawData="0640103020080ee"/>
 <Telegram Timestamp="2023-01-29T23:01:16.945Z" RawData="0640103020080aa"/>
 <Telegram Timestamp="2023-01-30T22:58:27.572Z" RawData="066040c02008067"/>
 <Telegram Timestamp="2023-01-30T22:58:27.606Z" RawData="066043402008067"/>
</CommunicationLog>

Would you like to work on this issue?

  • Yes
  • No

Bookmark this repository for further updates.

amitguptagwl added a commit that referenced this issue Feb 3, 2023
@amitguptagwl
Copy link
Member

fixed

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

No branches or pull requests

2 participants