Reputation: 9794
I would like to parse the following xml flow :
<telhdl:leg>
<tel:deviceId>82085625</tel:deviceId>
<tel:media>AUDIO</tel:media>
<tel:state>ACTIVE</tel:state>
<tel:capabilities>
<tel:drop>true</tel:drop>
<tel:hold>true</tel:hold>
<tel:mute>true</tel:mute>
<tel:sendDtmf>true</tel:sendDtmf>
</tel:capabilities>
</telhdl:leg>
<telhdl:leg>
<tel:deviceId>82085625</tel:deviceId>
<tel:media>VIDEO</tel:media>
<tel:state>ACTIVE</tel:state>
<tel:muted>true</tel:muted>-
<tel:capabilities>
<tel:drop>true</tel:drop>
<tel:unMute>true</tel:unMute>
</tel:capabilities>
</telhdl:leg>
As you can see, there is 2 groups of leg, but in one of them there is an attributes which is not present in the other (muted) for example.
I have tried to parse it using this code :
$(xmlDoc).find('telhdl\\\\:deviceId,deviceId');
with $(xmlDoc) is the document node.
It works fine, but i don't know how to parse correctly this file to have as result an array which contain information of the 2 legs block.
The question is more : How to have clerary a result of the parsing ?
Upvotes: 0
Views: 47
Reputation: 6822
This should do the trick:
$(xmlDoc).find("telhdl").each(function() {
var deviceId = $(this).find("deviceId").text();
var media = $(this).find("media").text();
....etc....
var array = new Array(deviceId,media,...etc...);
});
Upvotes: 2