@@ -37,7 +37,7 @@ import NumericMatcher from './matchers/NumericMatcher.js';
3737import LangMatcher from './matchers/LangMatcher.js' ;
3838import RepresentationBaseValuesMap from './maps/RepresentationBaseValuesMap.js' ;
3939import SegmentValuesMap from './maps/SegmentValuesMap.js' ;
40- import { parseXml as cmlParseXml } from '@svta/common-media-library/utils /parseXml.js' ;
40+ import { parseXml as cmlParseXml } from '@svta/common-media-library/xml /parseXml.js' ;
4141
4242// List of node that shall be represented as arrays
4343const arrayNodes = [
@@ -136,29 +136,29 @@ function DashParser(config) {
136136 }
137137
138138 function processXml ( data ) {
139- const root = cmlParseXml ( data ) . children . find ( child => child . tagName === 'MPD' ) ;
139+ const root = cmlParseXml ( data ) . children . find ( child => child . nodeName === 'MPD' ) ;
140140
141141 function processNode ( node ) {
142142 // Convert tag name
143- let p = node . tagName . indexOf ( ':' ) ;
143+ let p = node . nodeName . indexOf ( ':' ) ;
144144 if ( p !== - 1 ) {
145- node . __prefix = node . tagName . substr ( 0 , p ) ;
146- node . tagName = node . tagName . substr ( p + 1 ) ;
145+ node . __prefix = node . nodeName . substr ( 0 , p ) ;
146+ node . nodeName = node . nodeName . substr ( p + 1 ) ;
147147 }
148148
149- const { children, attributes, tagName } = node ;
149+ const { children, attributes, nodeName } = node ;
150150
151151 // Convert attributes
152152 for ( let k in attributes ) {
153153 let value = attributes [ k ] ;
154154
155- if ( tagName === 'S' ) {
155+ if ( nodeName === 'S' ) {
156156 value = parseInt ( value ) ;
157157 }
158158 else {
159159 for ( let i = 0 , len = matchers . length ; i < len ; i ++ ) {
160160 const matcher = matchers [ i ] ;
161- if ( matcher . test ( tagName , k , value ) ) {
161+ if ( matcher . test ( nodeName , k , value ) ) {
162162 value = matcher . converter ( value ) ;
163163 break ;
164164 }
@@ -174,25 +174,25 @@ function DashParser(config) {
174174 for ( let i = 0 ; i < len ; i ++ ) {
175175 const child = children [ i ] ;
176176
177- if ( typeof child === 'string ' ) {
178- node . __text = child ;
177+ if ( child . nodeName === '#text ' ) {
178+ node . __text = child . nodeValue ;
179179 continue ;
180180 }
181181
182182 processNode ( child ) ;
183183
184- const { tagName } = child ;
184+ const { nodeName } = child ;
185185
186- if ( Array . isArray ( node [ tagName ] ) ) {
187- node [ tagName ] . push ( child ) ;
186+ if ( Array . isArray ( node [ nodeName ] ) ) {
187+ node [ nodeName ] . push ( child ) ;
188188 }
189- else if ( arrayNodes . indexOf ( tagName ) !== - 1 ) {
190- if ( ! node [ tagName ] ) {
191- node [ tagName ] = [ ] ;
189+ else if ( arrayNodes . indexOf ( nodeName ) !== - 1 ) {
190+ if ( ! node [ nodeName ] ) {
191+ node [ nodeName ] = [ ] ;
192192 }
193- node [ tagName ] . push ( child ) ;
193+ node [ nodeName ] . push ( child ) ;
194194 } else {
195- node [ tagName ] = child ;
195+ node [ nodeName ] = child ;
196196 }
197197 }
198198
@@ -210,7 +210,7 @@ function DashParser(config) {
210210
211211 let ret = { } ;
212212 // If root element is xml node, then get first child node as root
213- if ( root . tagName . toLowerCase ( ) . indexOf ( 'xml' ) !== - 1 ) {
213+ if ( root . nodeName . toLowerCase ( ) . indexOf ( 'xml' ) !== - 1 ) {
214214 for ( let key in root ) {
215215 if ( Array . isArray ( root [ key ] ) ) {
216216 ret [ key ] = root [ key ] [ 0 ] ;
@@ -221,8 +221,8 @@ function DashParser(config) {
221221 }
222222 }
223223 } else {
224- ret [ root . tagName ] = root ;
225- delete root . tagName ;
224+ ret [ root . nodeName ] = root ;
225+ delete root . nodeName ;
226226 }
227227 return ret ;
228228 } catch ( e ) {
0 commit comments