0

xml parsing

CODEBOX
<actionsports>
<ContentType>action sports</ContentType>
<Title>Adventure Online TV AOTV 0001</Title>
<ShortDesc>Surfing</ShortDesc>

<Description>
Free Series with Peter Polanski, shows the skill and drive needed to succeed in the sports you participate in. This episode features Peter Polanski surfing in sebastian inlet, fl. He has the ability to be the next top surfer as long as he can stick to the path he's on
</Description>
<Streamurls>AOTVHalfHourClipShowEp1.mp4</Streamurls>
<Thumbnail>AOTVHalfHourClipShowEp1.jpg</Thumbnail>
<Actor1>Brian Karr</Actor1>
<Director>Brian Karr</Director>
<Duration>1200</Duration>
<Subscribed>1</Subscribed>
</actionsports>

<actionsports>
<ContentType>action sports</ContentType>
<Title>Mixed Martial Xtreme Fighting Championships 2</Title>

<ShortDesc>
Better known to fight fans as ‘XFC’, it’s the leading independent promotion of MMA events in the Southeast and stages some of the largest live shows in the sport this side of the UFC. Blessed with talented fighters, great fans and ‘action-packed’ events the ‘XFC’ is tireless in its efforts to bring exposure to their brand and launching the careers of mixed martial arts ‘Superstars’ of tomorrow.
</ShortDesc>

<Description>
Better known to fight fans as ‘XFC’, it’s the leading independent promotion of MMA events in the Southeast and stages some of the largest live shows in the sport this side of the UFC. Blessed with talented fighters, great fans and ‘action-packed’ events the ‘XFC’ is tireless in its efforts to bring exposure to their brand and launching the careers of mixed martial arts ‘Superstars’ of tomorrow.
</Description>
<Streamurls>XFCEpisode2.mp4</Streamurls>
<Thumbnail>XFCEpisode2.png</Thumbnail>
<Duration>1320</Duration>
<ReleaseDate>2008</ReleaseDate>
<Subscribed>1</Subscribed>
</actionsports>


i have xml file in which all child have not same elements. like in first child <actionsports> have <Duration> tag which is not present in nex child. so i want to insert some static value when i parse xml and push all element of xml into array. like i add here the code which is not working means it always goes into else block i want to jump in if block in children have not that type of element. how can i do this.? plz help me. thanx.
[color="#FF0000"][/color]
CODEBOX
if(request.status == 200)
{
var res = request.responseXML;
//getting the title for vedio
element = res.evaluate("actionsports-catalog/actionsports/Title");
//define the image for vedio
pic = res.evaluate("actionsports-catalog/actionsports/Thumbnail");
//define description for vedio
tit = res.evaluate("actionsports-catalog/actionsports/Description");
//define vedio
ved = res.evaluate("actionsports-catalog/actionsports/Streamurls");
//define duration
dur = res.evaluate("actionsports-catalog/actionsports/Duration");


/////define release date
dat = res.evaluate("actionsports-catalog/actionsports/ReleaseDate");


var temp = element.length;
var pictemp = pic.length;

//to show the total no of vedio in this catagories
//this.controls.backbutton.setText(pictemp);

events = [];
picevents = [];
titevents = [];
vedevents = [];
durevents = [];



datevents = [];

//push each title in array and make one array having title name
for (var i = 0; i < temp; i++) {
events.push({
name: element.item(i).firstChild.data,
});
}//end of loop
//end of array


//push each Description in array and make one array having release date
for (var i = 0; i < temp; i++) {
if(dat.item(i) === false)
{
datevents.push({
id: '100',
//name: dat.item(i).firstChild.data,
});
}
else
{
datevents.push({
id: i,
//name: dat.item(i).firstChild.data,
});
}
}//end of loop
//end of array


}

by
2 Replies
  • i just want to the excat code of if statement. that define that if children have not that type of tag then do this......but it will never goes into if block it always go into else block.
    may be my code is wrong for if codition.
    0
  • Why not just check for these at runtime instead of fussing with the XML stream coming in?
    0

Recent Posts

in Design / Interaction - Yahoo! TV Widgets