I want to get node from xml file.

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

Now I have to get data from node <Playlist> </ Playlist> success.

But.

I want read node separation between.

<FileName1> 01.mp4 </ FileName1>.
With.
<FileName2> 02.mp4 </ FileName2>.
To be independent.

What should I do.??

--- code --- PlaylistFile.xml

<? xml version = "1.0" encoding = "utf-8"?>
<PlaylistFile Xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
 
     <Playlist PlaylistName="Playlist_01">
        <FileName1> 01.mp4 </ FileName1>
        <FileName2> 02.mp4 </ FileName2>
     </ Playlist>
  
     <Playlist PlaylistName="Playlist_02">
        <FileName1> 03.mp4 </ FileName1>
        <FileName2> 04.mp4 </ FileName2>
     </ Playlist>
</ PlaylistFile>
--- code --- .js
var file = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory,"PlaylistFile.xml");
var blob = file.read();
var xmlMessage = blob.text;
var xmldata = Titanium.XML.parseString(xmlMessage);
var Playlist = xmldata.documentElement.getElementsByTagName("Playlist");
var listName = [];
 
for(var i = 0; i <  Playlist.length ; i++) {     
  listName[i] = Playlist.item(i).text; 
 
};
 
for(var i = (listName.length - 1); i >= 0 ; i--) {     
  alert("FileName[" + i + "]" + listName[i]);
};
 
var win1 = Titanium.UI.createWindow({  
     title:'Tab 1',
     backgroundColor:'#fff'
});
win1.open();
it now shows.

alert FileName[0]

01.mp4

02.mp4

and

alert FileName[1]

03.mp4

04.mp4


By.

01.mp4

02.mp4

Simultaneously show. Adjacent

-- Detailed --

Application type: mobile

Titanium Studio, build: 2.0.2.201205311912

titanium SDK Version: 2.1.1 GA.

Deployment Targets: Android 2.2

1 Answer

Your Answer

Think you can help? Login to answer this question!