Javascript, unable to parse XML child nodes

trapt

New Member
i've some troubles while parsing a xml response in my Javascript code (using extjs 4, but i think it doesn't matter here).The xml response is something like this:\[code\]<response> <id>9</id> <time>2012-05-24 14:22:44</time> <name>user</name> <message>message</message> <p2pchat> <requestor>user1</requestor> <requested>user2</requested> <time>2012-05-26 12:13:28</time> <message>msg</message> </p2pchat></response>\[/code\]I've no troubles parsing the 1st level elements like id, time, name and message, but my js code can't access the deeper ones. The code is:\[code\]var response = xmlHttpGetMessages.responseText;response = xmlHttpGetMessages.responseXML.documentElement;idArray = response.getElementsByTagName("id");nameArray = response.getElementsByTagName("name");timeArray = response.getElementsByTagName("time");messageArray = response.getElementsByTagName("message");requestorsArray = response.getElementsByTagName("p2pchat/requestor");requestedsArray = response.getElementsByTagName("p2pchat/requested");timep2pArray = response.getElementsByTagName("p2pchat/time");messagep2pArray = response.getElementsByTagName("p2pchat/message"); \[/code\]After this code executes, the length of the four last arrays is always 0, nothing has been fetched from my xml response.I've searched google for a way to parse inner elements in a xml tree but in 10 different pages i've found almost 10 different sintaxs, none seemed to work for me..any idea?
 
Back
Top