I have a XML which looks like this:
<?xml version="1.0" encoding="utf-8"?>
<!--
- phpMyAdmin XML Dump
- version 3.5.2.2
- http://www.phpmyadmin.net
-
- Host: 127.0.0.1
- Generation Time: Dec 04, 2013 at 06:05 PM
- Server version: 5.5.27
- PHP Version: 5.4.7
-->
<pma_xml_export version="1.0">
<!--
- Database: 'tvguide.ro'
-->
<database name="tvguide.ro">
<!-- Table tv_channels_programs -->
<table name="tv_channels_programs">
<column name="tv_channel_id">1</column>
<column name="ts_on">2013-12-04 01:00:00</column>
<column name="ts_off">2013-12-04 01:59:59</column>
<column name="title_l0">Poveştiri adevărate</column>
</table>
<table name="tv_channels_programs">
<column name="tv_channel_id">1</column>
<column name="ts_on">2013-12-04 02:00:00</column>
<column name="ts_off">2013-12-04 02:29:59</column>
<column name="title_l0">Poveştiri de noapte</column>
</table>
<table name="tv_channels_programs">
<column name="tv_channel_id">1</column>
<column name="ts_on">2013-12-04 02:30:00</column>
<column name="ts_off">2013-12-04 02:59:59</column>
<column name="title_l0">Cancan.ro</column>
</table>
The XML goes on like this for hundreds of Rows. What I am trying to achieve is this output:
For channel 1 from 2013-12-04 01:00:00 to 1013-12-04 01:59:59 is Povestiri adevarate
For channel 1 from 2013-12-04 02:00:00 to 1013-12-04 02:29:59 is Povestiri de noapte
...
Can I include also trace somehow? Thx
I managed to do it, here is the code for future reference:
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.events.Event;
import flash.utils.Timer;
import flash.events.TimerEvent;
var loader:URLLoader = new URLLoader();
loader.load( new URLRequest( "tv_channels_programs.xml" ) );
loader.addEventListener(Event.COMPLETE, handleComplete);
function handleComplete( event:Event ):void
{
var rawXML:XML = new XML( loader.data );
// extract all fields
var items:XMLList = rawXML.database.table;
//trace ("Total", items.length() );
for each( var item:XML in items )
{
//trace( item.column );
}
var titles:XMLList = rawXML.database.table.column;
for each( item in titles )
{
trace( item);
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.