my xml :
...
<phone type="cell" ext=""></phone>
<phone type="work" ext="">(123) 456 7890</phone>
...
in php; I json_encode($xml) and echo to browser. the browser recieves:
...
"phone": [
{
"@attributes": {
"type": "cell",
"ext": ""
}
}, "(123) 456 7890", {
"@attributes": {
"type": "work",
"ext": ""
}
}
]
in javascript
...
var phone_rec = {};
phone_rec.addPhone = function(argument, sender) {
function newPhone() {
this.phone = {};
this.phone.@attributes = {};
[email protected] = null;
[email protected] = null;
};
return newPhone();
}...
this falls apart and I am unable to reference this.phone for the number .
phone.@attributesis not valid JavaScript. Should bephone['@attributes'].