xml problem - omforme script til at hente data
Jeg er ved at omforme kode nederst , fra at hente data fre et xmldokument der ser sådan ud :
<?xml version="1.0"?>
<object name="New Object 001" description="This just text"/>
<object name="New Object 002" description="Weather today should be sunny"/>
osv.
til at hente data fra et xml dok der ser sådån her ud:
<?xml version="1.0" encoding="ISO-8859-1"?>
<allnews>
<news id="12">
<dato>12/12/02</dato>
<headline>overskrift</headline>
<smalltext>Fås i 3 udgaver</smalltext>
</news>
<news id="13">
<dato>12/12/02</dato>
<headline> ny overskrift</headline>
<smalltext>Fås så kun i 1 udgave</smalltext>
</news>
osv.
her er flash koden, som så ikke virker - hjælp !
// set the possibly shown errorDialog to be hidden
_root.errorDialog._visible = false;
stop();
// set the arrays to be used to hold our XML data
myContentHeadline = new Array();
myContentSmalltext = new Array();
// currentObj is used to keep track of the position we are in of the data
currentObj = 0;
// start it all off, load in the XML file to the function
loadContent("data.xml");
function loadContent(url){
myXML = new XML();
myXML.onLoad = buildContent;
myXML.load(url);
// not sure if this works totally, haven't debugged it yet, but it should throw an error if for some reason it can't load the XML file
if(myXML.loaded = false){
errorDialog._visible = true;
}
}
// main function to load XML, pull the data out and load it into our arrays
function buildContent(){
count = 0;
currentChild = this.firstChild;
findContent();
function findContent(){
// find all of the objects
if(count == 0){
if(currentChild.nextSibling != null){
currentChild = currentChild.nextSibling;
assignContent(currentChild);
}
}else{
if(currentChild.nextSibling.nextSibling != null){
currentChild = currentChild.nextSibling.nextSibling;
assignContent(currentChild);
}else{
tellTarget('newsTicker'){
goToAndPlay(2);
}
}
}
}
// load it into the arrays
function assignContent(){
myContentHeadline[count] = currentChild.attributes.headline;
myContentSmalltext[count] = currentChild.attributes.smalltext;
count++;
findContent();
}
}
