|
1 | 1 | 'use strict';
|
2 | 2 |
|
3 |
| -const xmlParser = require("fast-xml-parser"); |
| 3 | +const { XMLParser } = require('fast-xml-parser'); |
| 4 | +const xmlParser = new XMLParser({ignoreAttributes: false, removeNSPrefix: true, processEntities: false}); |
| 5 | +const xmlParserWithNs = new XMLParser({ignoreAttributes: false, removeNSPrefix: false, processEntities: false}); |
4 | 6 | const Device = require("./Device");
|
5 | 7 | const toArray = require("./toArray");
|
6 | 8 | const axios = require('./axios');
|
@@ -43,10 +45,10 @@ class MediaServer extends Device {
|
43 | 45 | })
|
44 | 46 | .catch(soapErrHandler)
|
45 | 47 | .then((response) => {
|
46 |
| - const data = xmlParser.parse(response.data, {ignoreAttributes: false, ignoreNameSpace: true}); |
| 48 | + const data = xmlParser.parse(response.data); |
47 | 49 | const browseResponse = data?.Envelope?.Body?.BrowseResponse;
|
48 | 50 | const didlResult = _.unescape(browseResponse?.Result);
|
49 |
| - const result = xmlParser.parse(didlResult, {ignoreAttributes: false}); |
| 51 | + const result = xmlParserWithNs.parse(didlResult); |
50 | 52 | const container = toArray(result["DIDL-Lite"].container);
|
51 | 53 | container.push(...(toArray(result["DIDL-Lite"].item)));
|
52 | 54 | browseResponse.Result = container;
|
@@ -84,10 +86,10 @@ class MediaServer extends Device {
|
84 | 86 | })
|
85 | 87 | .catch(soapErrHandler)
|
86 | 88 | .then((response) => {
|
87 |
| - const data = xmlParser.parse(response.data, {ignoreAttributes: false, ignoreNameSpace: true}); |
| 89 | + const data = xmlParser.parse(response.data); |
88 | 90 | const browseResponse = data?.Envelope?.Body?.BrowseResponse;
|
89 | 91 | const didlResult = _.unescape(browseResponse?.Result);
|
90 |
| - const result = xmlParser.parse(didlResult, {ignoreAttributes: false}); |
| 92 | + const result = xmlParserWithNs.parse(didlResult); |
91 | 93 | return {
|
92 | 94 | object: result["DIDL-Lite"].container || result["DIDL-Lite"].item,
|
93 | 95 | xml: browseResponse?.Result
|
@@ -117,7 +119,7 @@ class MediaServer extends Device {
|
117 | 119 | })
|
118 | 120 | .catch(soapErrHandler)
|
119 | 121 | .then((response) => {
|
120 |
| - const data = xmlParser.parse(response.data, {ignoreAttributes: false, ignoreNameSpace: true}); |
| 122 | + const data = xmlParser.parse(response.data); |
121 | 123 | return data?.Envelope?.Body?.GetSearchCapabilitiesResponse?.SearchCaps;
|
122 | 124 | });
|
123 | 125 | }
|
@@ -147,10 +149,10 @@ class MediaServer extends Device {
|
147 | 149 | })
|
148 | 150 | .catch(soapErrHandler)
|
149 | 151 | .then((response) => {
|
150 |
| - const data = xmlParser.parse(response.data, {ignoreAttributes: false, ignoreNameSpace: true}); |
| 152 | + const data = xmlParser.parse(response.data); |
151 | 153 | const searchResponse = data?.Envelope?.Body?.SearchResponse;
|
152 | 154 | const didlResult = _.unescape(searchResponse?.Result);
|
153 |
| - const result = xmlParser.parse(didlResult, {ignoreAttributes: false}); |
| 155 | + const result = xmlParserWithNs.parse(didlResult); |
154 | 156 | const container = toArray(result["DIDL-Lite"].container);
|
155 | 157 | container.push(...(toArray(result["DIDL-Lite"].item)));
|
156 | 158 | searchResponse.Result = container;
|
|
0 commit comments