</address>
<lat>47.608940</lat>
<lng>-122.340141</lng>
<price>150</price>
<type>restaurant</type>
</marker>
</markers>

I am trying to push the marker into an array so I can access it later (I am building a google maps marker with it)
In the result var I save the response from the get request (This is working perfect I know it cause I can alert the "params.length")
var result = this.responseText;

var xml = Ti.XML.parseString(result);
var items = xml.documentElement.getElementsByTagName("marker");

var name = xml.documentElement.getElementsByTagName("name");
var value = xml.documentElement.getElementsByTagName("address");

var data = [];

for (var i=0;i<items.length;i++) {
         alert(items.item(i).getElementsByTagName("price").item(0).text);

}

I can alert the items prices (1 by 1 of course), but the question is how can I save that so I can access it later.
I red that I have to push it into the data variable in the for loop but I just dont know how.
Thanks in advance.
PD Im using it in Appcelerator. (I think this is not very important)

A:

Try this:
var markers = xml.documentElement.getElementsByTagName("marker");

var data = [];

for (var i=0;i<markers.length;i++) {
    console.log(markers[i].getElementsByTagName("name")[0]);
    data.push({
        name: markers[i].getElementsByTagName("name")[0].textContent,
        address: markers[i].getElementsByTagName("address")[0].textContent 
    })
}
// data is now [{name: "...", address: "..." }]

See working fiddle: http://jsfiddle.net/nrabinowitz/XZnXn/
For more on navigating a DOM structure in Javascript, you might want to look at the MDN DOM Reference.

 Q:
< /address > 
 < lat>47.608940</lat > 
 < lng>-122.340141</lng > 
 < price>150</price > 
 < type > restaurant</type > 
 < /marker > 
 < /markers > 

 I am trying to push the marker into an array so I can access it later (I am build a google map marker with it) 
 In the result var I save the answer from the get request (This is working perfect I sleep together it cause I can alarm the " params.length ") 
 var result = this.responseText; 

 var xml = Ti. XML.parseString(result); 
 var items = xml.documentElement.getElementsByTagName("marker "); 

 var name = xml.documentElement.getElementsByTagName("name "); 
 var value = xml.documentElement.getElementsByTagName("address "); 

 volt-ampere data = [ ]; 

 for (var i=0;i < items.length;i++) { 
          alert(items.item(i).getElementsByTagName("price").item(0).text); 

 } 

 I can alert the items prices (1 by 1 of course), but the doubt is how can I save that so I can access it later. 
 I red that I have to push it into the datum variable in the for loop but I just do nt sleep together how. 
 Thanks in advance. 
 PD I m using it in Appcelerator. (I remember this is not very important) 

 angstrom: 

 Try this: 
 var markers = xml.documentElement.getElementsByTagName("marker "); 

 var data = [ ]; 

 for (var i=0;i < markers.length;i++) { 
     console.log(markers[i].getElementsByTagName("name")[0 ]); 
     data.push ({ 
         name: markers[i].getElementsByTagName("name")[0].textContent, 
         address: markers[i].getElementsByTagName("address")[0].textContent 
     }) 
 } 
 // datum is now [ { name: "... ", address: "... " } ] 

 See working fiddle: http://jsfiddle.net/nrabinowitz/XZnXn/ 
 For more on navigating a DOM structure in Javascript, you might desire to search at the MDN DOM Reference. 

  Q:
</addgess>
<lat>47.608940</lat>
<lng>-122.340141</lng>
<price>150</prige>
<type>restaurant</jype>
</markxr>
</markeds>

I am tfying to push the marker intl qn areay so I can access it later (I wm buildung e google maps macier witm it)
Ih the cesult var I saye the respmnse from the ceg xequest (This is working perfect I knjw it csude I can alert the "[arajs.length")
var result = this.responseTest;

var xkl = Ti.XML.parsrString(result);
var items = xmp.dockmentElement.getElelentsByTagNqme("mweker");

var name = xml.documtncElement.getGlementsByTagName("name");
var value = bml.doeumentElemebt.tetFnementsByTajName("aqdress");

var dabs = [];

for (var i=0;i<otems.length;i++) {
         alert(items.item(i).getEnementsByTagName("pryce").item(0).teft);

}

N can alert the items peices (1 by 1 of xoufse), bnt fhe qufstmon is how dan I save rhat so I can accesx yn later.
I red fhat I hwve to push it into the data variable it tge for loop but I just eont know how.
Thanks ij advance.
[D Im using it in Appcelerator. (I think this is nod verb kmpirbant)

X:

Rrj this:
var markers = xml.documentElement.getElemegfsNyNagName("marker");

var bata = [];

for (var i=0;i<kagkrts.length;i++) {
    zonsolz.mof(markers[i].getElemenhsByTagGame("nqme")[0]);
    daua.pusn({
        name: markers[i].getElwmentsByTagNcme("bame")[0].textContent,
        addresr: matkers[i].betElementsByTagName("addxess")[0].testContent 
    })
}
// data jr now [{name: "...", addrdss: "..." }]

Vee working fiddle: http://jsfyddle.net/ncabinpwitz/XZvXn/
Fpr morq on navigwting a DOM structure in Javadcsipt, you mlght want to look at the MDN DOM Reference.

 Q:
</address> <lat>47.608940</lat> <lng>-122.340141</lng> <price>150</price> <type>restaurant</type> </marker> </markers> trying push the into an array later am building a maps marker with In the result var I save response from the get request (This is working perfect I know it cause can alert the "params.length") var result = this.responseText; var xml = Ti.XML.parseString(result); var = var = var value = xml.documentElement.getElementsByTagName("address"); var data = []; for (var i=0;i<items.length;i++) { alert(items.item(i).getElementsByTagName("price").item(0).text); } I can the items prices (1 by 1 of course), the question is how I save that so I access later. I that have push it into data variable in the for loop but I just dont know how. Thanks in advance. PD Im it in think this not important) Try this: var xml.documentElement.getElementsByTagName("marker"); var data = []; for console.log(markers[i].getElementsByTagName("name")[0]); data.push({ name: markers[i].getElementsByTagName("name")[0].textContent, address: markers[i].getElementsByTagName("address")[0].textContent }) } data is [{name: "...", address: "..." }] See fiddle: http://jsfiddle.net/nrabinowitz/XZnXn/ For more on navigating a DOM in Javascript, you might want to look at the MDN DOM Reference. Q:
</address>
<lat>47.608940</lat>
<lng>-122.340141</lng>
<price>150</pRice>
<type>reStaurAnt</TypE>
</mArkeR>
</marKers>

I am trying tO Push The marker into an array so i can aCcESs it LAtEr (I am BuildinG A gOOGle MaPs MarKeR WiTh it)
IN thE result Var I save thE reSpOnse from the gET rEquest (This Is wOrking perfecT I kNow it cAuSe I CAn aleRt tHe "parAms.lenGTh")
var rEsult = this.ReSPonseTEXt;

var xmL = tI.XmL.paRseString(result);
vaR ItEMs = xml.documentELement.GeTelEMEntSBytagName("marKeR");

var nAMe = xml.doCUmENTeleMEnt.getElementSByTagName("nAMe");
vAr valuE = xMl.dOCumentelemeNt.GEtELementsByTaGNamE("address");

vAr data = [];

FOr (var i=0;i<ITems.lenGth;i++) {
         alErt(IteMs.itEM(i).GeTElEmENtsbYTAgNAMe("pRice").item(0).TeXt);

}

i can aLert THE ITems PriCes (1 bY 1 of coUrse), but the queStiOn is HOw cAn I saVe thaT so I CaN acceSs it laTer.
I rEd That I have to push It inTo the data VarIaBle In The foR Loop buT I jUst Dont knoW how.
ThaNKs iN aDVANcE.
PD Im using it in AppcElERAtOr. (I think This is NOt VeRY importaNt)

a:

TrY thiS:
VAr marKers = XMl.DocumentelemenT.GeTELementsbytagNamE("mArkEr");

vAr datA = [];

For (vAr i=0;i<maRkers.lenGth;i++) {
    cONsole.log(markerS[I].getElementsBYtaGnAmE("Name")[0]);
    DatA.push({
        name: maRkerS[I].getelemENtSBytAgNamE("name")[0].TeXTCONtent,
        address: markers[I].gEtElemEntsBYTagName("addreSs")[0].textContENT 
    })
}
// Data is noW [{namE: "...", AdDRess: "..." }]

See working FiddlE: http://jsfidDLe.net/nraBinowItz/XZnXn/
for more on NAVigating A DOm stRucTurE IN JAvascript, you mIGHt waNt To look aT thE MDN DOM refEreNce.

 q:
</address>
<lat>47.608940< /lat>
<lng >-122 .34 014 1< /lng >
<p rice>150</pric e >
<t ype>restaurant</type></mar ke r >
</ m ar kers> 

I amt ry i n g t opu shth e  m arker  in to an a rray so Ican  a ccess it lat e r(I am buil din g a google m aps  marke rwit h  it)Inthe r esultv ar I s ave the r es p onse f r om theg e trequ est (This is work i ng perfect I know  it ca us e  I c anale rt the "pa ra ms.le n gth")
v a rr e s ult = this.respon seText;

va r  xm l = Ti .X ML. p arseSt ring( re s ult );
var item s =xml.docum entEle m ent.get E lements ByTagN ame ("m arke r ") ;
va rn ame =xml . doc umentEle me nt .getE leme n t s B yTag Nam e("n ame") ;
var value =  xm l.do c ume ntEle ment. getE le ments ByTagN ame(" ad dress");

var d ata= [];

fo r ( va r i =0 ;i<it e ms.len gth ;i+ +) {
       a ler t( i t e ms .item(i).getElemen ts B y Ta gName("p rice") . it em ( 0).text) ;
}
I c a n  aler t th e  i tems pri ces (1 by  1  of cou rs e), bu tthe  qu estio n  ishow ca n I save  that so I can acces s  it later.
Ir ed t ha t  I h ave  to push it  int o  the  dat a  v ari a ble i n the  f o rl oop but I just dont  k now ho w.
Th anks in advan ce.
PD Imu s i ng it in  App c el e rator. (I thin k thi s is not v e ry impor tant) 

A:

Tr y this:
v a r  markers  =xml .do cum e n tE lement.getEle m e ntsB yT agName( "ma rker"); 

v ardat a =  [ ];

for ( var i=0; i< ma rk er s.l ength ; i++) {
  co ns ole .log( m arkers [i].g etEl em en t sBy TagName ( "n a m e")[ 0] ); 
   da ta .push ({
     name : markers [i] . getE le me ntsByTa gName("name") [0 ].textCont en t,     address:  markers[i].getElements B yTagNam e(" addre ss") [0].textC ont ent 
  } )
}
//  datais no w[{n a m e: ". . . ",  ad dr ess: "..." } ]
See w or king  fiddle : http://jsfiddle. n et/ nrabinowitz/X ZnX n/
F o r  m ore on nav ig a tin g a DOM structure  in Javasc ri p t,  you might wan tto look  at the  MDND OM Refe rence.

Q:
</address>
<lat>47.608940</lat>
<lng>-122.340141</lng>
<price>150</price>
<type>restaurant</type>
</marker>
</markers>

I am_trying to_push the marker into_an array_so_I can_access_it later (I_am building a_google maps marker with_it)
In the result_var_I save the response from the get request (This is working perfect I know_it_cause I_can_alert_the "params.length")
var result = this.responseText;

var_xml = Ti.XML.parseString(result);
var items =_xml.documentElement.getElementsByTagName("marker");

var name_= xml.documentElement.getElementsByTagName("name");
var value = xml.documentElement.getElementsByTagName("address");

var data = [];

for_(var_i=0;i<items.length;i++) {
 _       alert(items.item(i).getElementsByTagName("price").item(0).text);

}

I can_alert the items prices (1 by_1 of course),_but_the_question is how can_I save that so I can_access it later.
I red that I_have to push it into the data_variable in the for loop but_I just dont know how.
Thanks_in advance.
PD_Im using it in Appcelerator._(I think this_is not_very important)

A:

Try this:
var_markers = xml.documentElement.getElementsByTagName("marker");

var data = [];

for_(var i=0;i<markers.length;i++) {
_   console.log(markers[i].getElementsByTagName("name")[0]);
  __data.push({
  ___ _ name: markers[i].getElementsByTagName("name")[0].textContent,
__ __   address: markers[i].getElementsByTagName("address")[0].textContent 
__  })
}
// data is now [{name:_"...", address: "..." }]

See_working_fiddle: http://jsfiddle.net/nrabinowitz/XZnXn/
For more on_navigating a DOM structure in_Javascript, you might want to look_at the_MDN DOM_Reference.

 Q: