Closed croghostrider closed 1 year ago
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)
<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>
<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?
Bookmark this repository for further updates.
fixed
Description
Hi @amitguptagwl, i found the problem with the unpairedTags parameter. If i set ignoreAttributes to false the paramter unpairedTags is ignored. ### InputCode
Output
expected data
Would you like to work on this issue?
Bookmark this repository for further updates.