| | #1 |
| Senior Warrior Member War Room Member Join Date: 2006 Location: Mars
Posts: 1,133
Thanks: 152
Thanked 310 Times in 223 Posts
Blog Entries: 2 |
I get tryng to work this code. First I would like to add all items within "Feature" tags. Each time I run it , I only get the last item "TriZone". How can get all items and add a line break ? Top Part shows the output I am getting from Amazon and second part shows the function I am using to get the information. Code:
<Feature>Rechargeable </Feature>
<Feature>Dynamic </Feature>
<Feature>manual</Feature>
<Feature>TriZone</Feature>
*****************
function getinfo(){
var o = {};
var a = response.getDescendants();
for(var i=0;i<a.length;i++) {
if(a[i].getType() == XmlService.ContentTypes.ELEMENT){
switch(a[i].asElement().getName()){
case "Feature" :
o.feature = a[i].asElement().getText();
}
}
} I am also trying to get "URL" value from this but no luck. How can I get URL element? Code:
<SmallImage>
<URL>http://ecx.images-amazon.com/images/I/313lIweldTL._SL75_.jpg</URL>
<Height Units="pixels">75</Height>
<Width Units="pixels">41</Width>
</SmallImage>
<MediumImage>
<URL>http://ecx.images-amazon.com/images/I/313lIweldTL._SL160_.jpg</URL>
<Height Units="pixels">160</Height>
<Width Units="pixels">87</Width>
</MediumImage>
***********************
function getinfo(){
var o = {};
var a = response.getDescendants();
for(var i=0;i<a.length;i++) {
if(a[i].getType() == XmlService.ContentTypes.ELEMENT){
switch(a[i].asElement().getName()){
case "SmallImage" :
o.smallimage = a[i].asElement().getText();
}
}
} Thanks |
| |
| | #2 |
| HyperActive Warrior War Room Member Join Date: 2009
Posts: 156
Thanks: 1
Thanked 11 Times in 10 Posts
|
Just a quick guess try changing "for(var i=0;i<a.length;i++) {" to " for(i in a) {". No guarantee it will work. You need to find out exactly what "response.getDescendants(); " is returning.
|
| | |
| |
|
| Bookmarks |
| Tags |
| hhojavascript, javascript |
| |