使用Javascript访问JSONparsing的SOAP信封

这是我的第一篇文章,我对这个奇妙的发展世界是新的,所以如果这是一个愚蠢的问题,我提前道歉。

我正在使用Xml2js发送肥皂请求。 然后我把这个响应parsing成json。 我的问题是深入到肥皂信封。 这就是响应的样子:

{ 'soap:Envelope': { '$': { 'xmlns:soap': 'http://schemas.xmlsoap.org/soap/envelope/' }, 'soap:Header': [ [Object] ], 'soap:Body': [ [Object] ] } }

这是一个扩大的观点

 { 'soap:Envelope': { '$': { 'xmlns:soap': 'http://schemas.xmlsoap.org/soap/envelope/' }, 'soap:Header': [ { DWHeader: [ { '$': { xmlns: 'Some Xmls' }, SenderInfo: [ { ApplicationID: [ 'Id' ], Credentials: [ { AuthToken: [ 'Authtoken' ] } ] } ], GlobalTimeoutMS: [ '123' ], TrackingID: [ '123' ], TraceResults: [ { TraceResult: [ { IPAddress: [ '0.0.0.0' ], Instance: [ '123' ], Actor: [ '123' ], Timestamp: [ '2015-08-08T15:45:40.844Z' ], DetailedMessage: [ '123' ] } ] } ], TraceSettings: [ { '$': { Enabled: 'false' } } ] } ] } ], 'soap:Body': [ { GetCurrentLocationOfAllMobilesResponse: [ { '$': { xmlns: 'Some xmls' }, Tracks: [ { Track: [ { Id: [ 'Id' ], TimeStamp: [ '2015-09-14T21:09:47Z' ], HardwareId: [ 'Some id' ], MobileName: [ 'Truck' ], Lat: [ 'Some Lat' ], Lon: [ 'Some Lon' ], Heading: [ '0' ], Speed: [ '0' ], GPSLock: [ 'true' ], Old: [ 'false' ], Ping: [ 'false' ], Motion: [ 'false' ], Speeding: [ 'false' ], Ignition: [ 'false' ], IgnitionStatus: [ 'Engine Off' ], Street: [ 'Address' ], City: [ 'Some City' ], StateProvince: [ 'Some State' ], PostalCode: [ 'Some Zip' ], County: [ 'Some County' ], Rssi: [ '32' ], Sats: [ '11' ], TimeZone: [ 'Some Timezone' ], Sensor1: [ 'true' ], Sensor2: [ 'false' ] } ] } ] } ] } ] } } 

我需要Track数组,但是当我尝试钻取时,我遇到了“soap:Envelope”和“soap:Body”的问题。

这是我的第一个问题,所以如果我没有发布足够的信息让我知道,我会包括更多。

谢谢!

你有没有试过使用括号?

 var tracksArray = response['soap:Envelope']['soap:Body'][0].GetCurrentLocationOfAllMobilesResponse[0].Tracks 

有关支架表示法的更多信息,请参阅以下答案: https : //stackoverflow.com/a/4968448/4178531