PDA

View Full Version : melting pot of XML-Html-CSS


Selrache
12-13-2003, 01:40 PM
hullo....
i'm new a this action scripping stufff.... but with all the tutorial and alll i was able to learn a lot from this site... but my buss want me to do some testing and a bug whit a problem and i don't understand it doesn't work....

here is the case... i have and HTML code inside a XML.... I call the XML in flash and put it in a textfeild... but when i try to apply a CSS on the textfeild but it does find the classe='heading' in the HTML tag...

WHY!!!!! since the texfeild is html doesn't it interpret the XML as html???

is it just me or what i'm trying to do is impossible???

thanks!

Stimpson
12-16-2003, 05:49 AM
Hey and welcome here Selrache,

but when i try to apply a CSS on the textfeild but it does find the classe='heading' in the HTML tag...Are you sure the css is completely loaded? Try assiging the html text after the onLoad of the css has fired.

Mortimer Jazz
12-16-2003, 08:22 AM
it would be helpful to see the code too if you can post some :)

Selrache
12-16-2003, 01:33 PM
Stimpson:
the css is completely load the trace tell me it's all there!
I've try to put the css before the xml but it doesn't change a thing!!!:(

Mortimer:
ok here's the code... it's basicaly the same thing as the tutrorial on css with the exeption that I put the texte in a XML file...
var ftexte = ("ftexte.xml");

texte_xml = new XML();
texte_xml.ignoreWhite = true;
texte_xml.onload = function(ok){
if (ok){
btitre = (texte_xml.firstchild.childNodes[0].firstChild.toString());
btexte= (texte_xml.firstchild.childNodes[1].firstChild.toString());
photo = (texte_xml.firstchild.childNodes[2].firstChild.nodeValue);
trace(btexte);
}
else{
trace("error loading xml");
}
}

texte_xml.load(ftexte);

var myCSS = new TextField.StyleSheet();
var cssURL = "styles.css";
myCSS.load(cssURL);
myCSS.onLoad = function(success) {
if (success) {
myText.styleSheet = myCSS;
myText.text = btexte;
trace(this.getStyleNames());
}
};
hope you can help me!!!




Please use the proper code syntax to format the code.
Read this page (http://www.actionscript.org/forums/misc.php3?action=bbcode#buttons) to find out more about the tag information.
Using this feature will assist people in reading and understanding your code and hopefully help you get better assistance. Best of all, it's easy to use; all you have to do is enter your code between a [ as ] tag and a [ /as ] tag. For example, try [ as ]trace("This is a test");[ /as ](Get rid of the space between the open/close brackets('[' and ']')

Mortimer Jazz
12-16-2003, 01:53 PM
In your XML you're putting <tag class='heading'> instead of using <heading> tags? Am I right?

If so, then are you creating style classes in the CSS or defining new tags?

For example, are you doing this:
mytag { prop: value; }

or
.mytag {prop: value;} //with added "."

?????

Selrache
12-16-2003, 01:57 PM
i'm using basic html tag in xml like:

<p class="heading">blablabla</p>

and i'm using:

.mytag [prop: value;} //with added "."

Mortimer Jazz
12-16-2003, 02:05 PM
hmmm okay *wanders off to think*

Mortimer Jazz
12-16-2003, 02:18 PM
Are you using a textbox or TextArea component?

Have you tried validating your XML incase it's not well-formed?
You could try running something like this:

var ftexte = ("ftexte.xml");
//xml stuff
texte_xml = new XML();
texte_xml.onLoad = function () {
myText.text = btexte;
if(texte_xml.status == 0){
trace("No Errors encountered");
}else{
trace("Error encountered is: " + texte_xml.status);
}
}
texte_xml.load(ftexte);
/*
0 No error; parse was completed successfully.
-2 A CDATA section was not properly terminated.
-3 The XML declaration was not properly terminated.
-4 The DOCTYPE declaration was not properly terminated.
-5 A comment was not properly terminated.
-6 An XML element was malformed.
-7 Out of memory.
-8 An attribute value was not properly terminated.
-9 A start-tag was not matched with an end-tag.
-10 An end-tag was encountered without a matching start-tag.
*/

Get any errors from that?

Selrache
12-16-2003, 03:35 PM
I get the "no errors encountered"
but in my texte box now I get:
<TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="Arial" SIZE="12" COLOR="#000000">&lt;p align=&quot;left&quot;&gt;&lt;/p&gt;</FONT></P></TEXTFORMAT>

wich is the propety config of the textebox!!!

I must be doing somthing wrong.. but i can't figure it out yet!!!:(

Stimpson
12-16-2003, 03:48 PM
Hey,

Bit of a open door but have you set the html prop of the textfield to true, I suppose you did :).

Try loading the css in the onload of the xml, and in turn assigning the text in the onload of the css. Other then that I'm a bit clueless right now :(.

On a sidenote: Who's that on your new IMG Mortimer Jazz, looks a bit like that guy the arrested a couple of days ago (kidding) :D :).

Selrache
12-16-2003, 06:42 PM
For some obscure reason I made it work!!!

here is the code!!!
var ftexte = ("essaie.xml");
//xml stuff
texte_xml = new XML();
texte_xml.onLoad = function () {
//trace(texte_xml);
if(texte_xml.status == 0){
bob = texte_xml.childNodes[1].childNodes[3].toString();
trace(bob);
trace("No Errors encountered");
}else{
trace("Error encountered is: " + texte_xml.status);
}
}
texte_xml.load(ftexte);

var myCSS = new TextField.StyleSheet();
var cssURL = "styles.css";
myCSS.load(cssURL);
myCSS.onLoad = function(success) {
if (success) {
myText.styleSheet = myCSS;
myText.text = bob;
trace(this.getStyleNames());
}
};
BUT ... there is always a dam but!!!
Can someones explain to me why :
bob = texte_xml.childNodes[1].childNodes[3].toString();

and not:
texte_xml.childNodes[0].childNodes[1].toString():

since my XML is:
<?xml version="1.0" encoding="UTF-8"?>
<essaie>
<texte>
<titre>asdlfghlsdfhg</titre>
</texte>
<description>
<p class="headline">titre</p>
<p><span class="byline">Bath, UK</span>--Flash developer NWebb seemed to take forever to finish his CSS-Flash tutorial, but it is finished now and you can find it <a href="http://www.nwebb.co.uk">here</a> along with a few others.
<ul>
<li class="titre">liste1</li>
<li class="stitre">liste2</li>
<li class="texte">liste3</li>
<li>
<a href="sdfgsdrg.htm" target="_blank" class="liens">liste4</a>
</li>
</ul>
</p>
</description>
</essaie>
Thanks...

Mortimer Jazz
12-17-2003, 05:29 AM
Selrache, are you using texte_xml.ignoreWhite=true anywhere?

Stimpson, that's my mum ;]

Stimpson
12-17-2003, 08:27 AM
Can someones explain to me why :
bob = texte_xml.childNodes[1].childNodes[3].toString();

and not:
texte_xml.childNodes[0].childNodes[1].toString();Try using nodevalue instead of toString, perhaps that will do it.

Stimpson, that's my mum ;]Really?.........that is bad ;).

Selrache
12-17-2003, 11:53 AM
Mortimer...
Doh... but it does the trick.... thanks...

Stimpson...
Can't use the nodevalue because the node contain other nodes...
but i try anyway just to be sur and it gave me a null info...


why does my closse tag </p> doesn't goes on the other line???
or do i have to define that somewhere???

thank...

Note:I know my english is quite poor... it is not my native language!!!

hipster
12-23-2003, 04:32 PM
not sure if this helps...but I've been discovering XML behaves very odd when putting HTML tags in it unless you use the pain in the ass way of doing the carrots...

<myXML>
<b>doggy</b>
</myXML>

You need to use &lt; instead of the <
You need to use &gt; instead of the >

which makes this...

<myXML>
&lt;b&gt;doggy&lt;/b&gt;
</myXML>

or else mine bombs.