Data la seguente stringa XML
opportunamente parsata come documento XML, come si accede al contenuto di timestamp?codice:<XMLresponse> <ticket date="24.12.2007"> <timestamp>12918723498</timestamp> <text>Testo</text> </ticket> </XMLresponse>
Codice PHP:
// funziona:
var ticket = XMLdoc.getElementsByTagName('ticket');
alert(msg[0].getAttribute('date')); // restituisce la data
// non funziona:
var timestamp = XMLdoc.childNodes[0].childNodes[0].nodeValue;
alert(timestamp); // restituisce "null"
// anche questa restituisce null:
var timestamp = XMLdoc.getElementsByTagName('timestamp');
alert(timestamp[0].nodeValue);
![]()

Rispondi quotando