XML parsing

You must Login before you can answer or comment on any questions.

I have always been bad at handling XML :( I could use your info on how to parse this one

<?xml version="1.0" encoding="UTF-8"?>
<query columns="7" rows="1">
<row>
    <createdat>2010-04-13 00:00:00.0</createdat>
    <id>1</id>
    <latitude>1.12312</latitude>
    <longitude>-1.12312</longitude>
    <message>This is a test</message>
    <photourl></photourl>
    <updatedat></updatedat>
</row>
</query>
I would like to read that "rows" attribute in order to know how long my loop will be

2 Answers

Accepted Answer

//the following creates a list of everything contained in your row response

var itemList = xml.documentElement.getElementsByTagName("row");
//the following gets the values within your row response
var created = itemList.item(0).getElementsByTagName("createdat").item(0).text;

Turns out this was the answer...

this.responseXML.documentElement.getAttribute("rows")

Your Answer

Think you can help? Login to answer this question!