-
- Notifications
You must be signed in to change notification settings - Fork 336
Closed
Labels
Description
- 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.