Hey, I was wondering if it would be possible to style text from an xml file with css based on the the tag name in the xml file…
<?xml version="1.0"?>
<news>
<article>
<title>Whatever</title>
<body>Text in here</body>
<image>pathToImage.jpg</image>
</article>
</news>
this is the script I’m using to load the xml
var numArts:Number = 0;
function loadXML(loaded) {
if (loaded) {
_root.totalArts = this.firstChild.childNodes.length;
_root.titleTxt = this.firstChild.childNodes[numArts].childNodes[0].firstChild.nodeValue;
_root.bodyTxt = this.firstChild.childNodes[numArts].childNodes[1].firstChild.nodeValue;
_root.image = this.firstChild.childNodes[numArts].childNodes[2].firstChild.nodeValue;
bodyTxtNR = _root.bodyTxt.split("\r").join("");
bodyTxtNT = _root.bodyTxtNR.split(" ").join("");
loadImage = _root.container.loadMovie(image);
title_txt.text = _root.titleTxt;
body_txt.text = _root.bodyTxtNT;
number_txt.text = "Article: "+(numArts+1)+"/"+(totalArts);
} else {
trace("file not loaded!");
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("news.xml");
prev_btn.onPress = function() {
if (numArts>=1) {
numArts -= 1;
} else {
numArts = totalArts-1;
number_txt.text = "Article: "+(-1+numArts)+"/"+(totalArts);
}
xmlData.load("news.xml");
};
next_btn.onPress = function() {
if (numArts<totalArts-1) {
numArts += 1;
} else {
numArts = 0;
number_txt.text = "Article: "+(numArts+1)+"/"+(totalArts);
}
xmlData.load("news.xml");
};