# \[XML\] text style

**URL:** https://forum.kirupa.com/t/xml-text-style/19147
**Category:** programming
**Created:** [April 24, 2003, 6:04pm UTC](https://forum.kirupa.com/t/xml-text-style/19147 "2003-04-24T18:04:11Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![thediablo](https://avatars.discourse-cdn.com/v4/letter/t/c37758/32.png) [@thediablo](https://forum.kirupa.com/u/thediablo)
#### Post date: [April 24, 2003, 6:04pm UTC](https://forum.kirupa.com/t/xml-text-style/19147/1 "2003-04-24T18:04:11Z")

</div>

well i read on how to make a dynamic menu with xml, but thats not what i wanna do and i cant get it to work with the AS to suit my needs.

so what i have is

```php

 
  <newsmain>
     <article>
       <title>Some title</title>
       <date>some date</date>
       <autor>Some silly name</autor>
     </article>
     <article>
       <title>Some title</title>
       <date>some date</date>
       <autor>Some silly name</autor>
     </article>
     <article>
       <title>Some title</title>
       <date>some date</date>
       <autor>Some silly name</autor>
     </article>
   </newsmain>

  

```

i have that xml stuff…

i need to give it some format, some html tags maybe font color… bold… etc…

i want to load that in a text box.

Please help?

Thanks 🙂

(i alredy read the senocular kirupra tuts and nada)

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [April 24, 2003, 6:17pm UTC](https://forum.kirupa.com/t/xml-text-style/19147/2 "2003-04-24T18:17:02Z")

</div>

```php

menuXml = new XML();
menuXml.ignoreWhite = true;
menuXml.onLoad = function() {
	menuItem = this.firstChild.childNodes;
	for (var i=0; i<menuItem.length; i++) {
		item = _root.attachMovie("itemClip", "itemClip" + i, i);
		item._x = 0;
		item._y = 20*i;
		item.itemLabel.text = menuItem*.attributes.name;
		item.myUrl.text = menuItem*.attributes.url;
		//item.onRelease = function() {
		//	getURL(this.myUrl,"_blank");
		//}
	}
}
menuXml.load("menu.xml");

```

im using that taking the menu tutorial for reference.  
i created a movie clip naed itemClip and that duplicates depending on the num of nodes.

so i just made 2 dynamic text fields (itemLabel, myUrl)  
and the text displays ok there…

but… is this the most efficent way to do it?

also is not in a TEXTBOX so … HELP!!!

Thanks 😃

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [April 25, 2003, 2:30pm UTC](https://forum.kirupa.com/t/xml-text-style/19147/3 "2003-04-25T14:30:24Z")

</div>

help me ☹

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [April 25, 2003, 4:39pm UTC](https://forum.kirupa.com/t/xml-text-style/19147/4 "2003-04-25T16:39:05Z")

</div>

[AS]item.itemLabel…html = true;  
item.itemLabel.htmlText = menuItem\*.attributes.name;  
item.myUrl.html = true;  
item.myUrl.htmlText = menuItem\*.attributes.url;[/AS]

To be able to use font formatting tags like that you have to render the textboxes to read HTML (albeit limited font formatting HTML, but still HTML none the less).

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [April 30, 2003, 6:12pm UTC](https://forum.kirupa.com/t/xml-text-style/19147/5 "2003-04-30T18:12:46Z")

</div>

THANKS Lost!

im understanding it better…

but i want to put the HTML tags in the AS, any example to get started?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [April 30, 2003, 6:21pm UTC](https://forum.kirupa.com/t/xml-text-style/19147/6 "2003-04-30T18:21:35Z")

</div>

Why not just add it with your text in the XML file? It would be easier on you if thats the text you want to be effected by your font formatting HTML tags.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [April 30, 2003, 6:31pm UTC](https://forum.kirupa.com/t/xml-text-style/19147/7 "2003-04-30T18:31:28Z")

</div>

but then i will have a big xml full of tags?

i want the AS To loop and loop and format each node itself.

what u think?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [April 30, 2003, 6:33pm UTC](https://forum.kirupa.com/t/xml-text-style/19147/8 "2003-04-30T18:33:59Z")

</div>

Well then add the tags in the AS.

[AS]item.itemLabel.htmlText = “\<B\>”+menuItem\*.attributes.name;+"\</B\>"[/AS]

Something like that should work.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [April 30, 2003, 6:38pm UTC](https://forum.kirupa.com/t/xml-text-style/19147/9 "2003-04-30T18:38:26Z")

</div>

nice.

gonna make some examples and see if it works

thanks man 🙂

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [April 30, 2003, 6:43pm UTC](https://forum.kirupa.com/t/xml-text-style/19147/10 "2003-04-30T18:43:47Z")

</div>

Question though: If the entire text is those textboxes are all going to have the same format… why not just format it like that on the textbox itself through the properties?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [April 30, 2003, 6:52pm UTC](https://forum.kirupa.com/t/xml-text-style/19147/11 "2003-04-30T18:52:25Z")

</div>

no that was an example

the text i want to put it in 1 textbox only and fill it automatically with the XML/AS so if i update something i just add nodes and text. and the AS does the text format.

and i wanna do it scrollable…

no problem with the things we got so far right?

thanks!

Be back tomorrow!

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [April 30, 2003, 7:19pm UTC](https://forum.kirupa.com/t/xml-text-style/19147/12 "2003-04-30T19:19:17Z")

</div>

Alright… I thought you were using seperate textboxes for each thing, in that case it would have been easier to format the textboxes manually, but since it is just one textbox, you can’t do that, so I understand now.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [May 2, 2003, 3:59pm UTC](https://forum.kirupa.com/t/xml-text-style/19147/13 "2003-05-02T15:59:06Z")

</div>

almost there… i think

ok here is what i got.

```php

the AS.
menuXml = new XML();
menuXml.ignoreWhite = true;
menuXml.onLoad = function() {
	menuItem = this.firstChild.childNodes;
	for (var i=0; i<menuItem.length; i++) {
	_root.itemClip.html = true;
    _root.itemClip.htmlText = "<br><b>"+menuItem*.attributes.name+"</b><br>"+menuItem*.attributes.url;

	}
}
menuXml.load("menu.xml");

```

```php

the XML FILE

<?xml version="1.0"?>	
<myMenu>	
<myItem name="Philter" url="http://www.philterdesign.com/" />
		<myItem name="Keran McKenzie" url="http://pnut.studiowhiz.com/" />		
<myItem name="StudioWhiz" url="http://www.studiowhiz.com/" />		
<myItem name="Macromedia" url="http://www.macromedia.com/" />		
<myItem name="FlashForward" url="http://www.flashforward2002.com/" />
		<myItem name="Electric Rain" url="http://www.erain.com/" />
		<myItem name="Friends of Ed" url="http://www.friendsofed.com/" />
		<myItem name="Swish" url="http://www.swishzone.com/" />
		<myItem name="New Riders" url="http://www.newriders.com/" />
		<myItem name="LastNode" url="http://www.sorenson.com/" />	
</myMenu>

```

is just an example file…

i got 1 Dynamic box, named itemClip in 1 frame with the AS in the frame.

when i run the test it displays the LastNode (last item on list) only.

why is that?

maybe the for loop is wrong? but it seems ok.

lil help almost there.
