# Flash MX: XML News

**URL:** <https://forum.kirupa.com/t/flash-mx-xml-news/119024>\
**Category:** Uncategorized\
**Created:** [August 10, 2004, 11:58pm UTC](https://forum.kirupa.com/t/flash-mx-xml-news/119024 "2004-08-10T23:58:06Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![fatnslow](https://avatars.discourse-cdn.com/v4/letter/f/7993a0/32.png) [@fatnslow](https://forum.kirupa.com/u/fatnslow)\
**Post date:** [August 10, 2004, 11:58pm UTC](https://forum.kirupa.com/t/flash-mx-xml-news/119024/1 "2004-08-10T23:58:06Z")

</div>

Hey, I wonderd how I could make an XML, or php, news. I have thought it like this:

I have an member section, with user and password, and in the section I want the the logged in user to be able to post a news that shows up in the home.swf.  
If the user could send the info (name, date, message) to an xml file, then in the home.swf a dynamic field could read the xml and, it would show up.

Could anyone help?

If possible, I would like the output in the home.swf to be something like this :

```auto
 - fatnslow, 01.09.04 - 
bla bla bla bla bla bla bla
bla bla bla bla bla bla bla
bla bla bla bla bla bla bla
 
- fatnslow, 29.08.04 - 
bla bla bla bla bla bla bla
bla bla bla bla bla bla bla
bla bla bla bla bla bla bla

```

thanks,  
fatnslow

---

<div class="post-metadata">

**Author:** ![Dulcinea](https://avatars.discourse-cdn.com/v4/letter/d/bbe5ce/32.png) [@Dulcinea](https://forum.kirupa.com/u/Dulcinea)\
**Post date:** [August 11, 2004, 4:33am UTC](https://forum.kirupa.com/t/flash-mx-xml-news/119024/2 "2004-08-11T04:33:41Z")

</div>

this tutorial can give you an idea  
[http://www.kirupa.com/web/xml\_guestbook.htm](http://www.kirupa.com/web/xml_guestbook.htm)

---

<div class="post-metadata">

**Author:** ![fatnslow](https://avatars.discourse-cdn.com/v4/letter/f/7993a0/32.png) [@fatnslow](https://forum.kirupa.com/u/fatnslow)\
**Post date:** [August 11, 2004, 5:39am UTC](https://forum.kirupa.com/t/flash-mx-xml-news/119024/3 "2004-08-11T05:39:31Z")

</div>

Hmmm, I tried some, but really need some help…  
To much AS at one time there…could anyone help please?

---

<div class="post-metadata">

**Author:** ![fatnslow](https://avatars.discourse-cdn.com/v4/letter/f/7993a0/32.png) [@fatnslow](https://forum.kirupa.com/u/fatnslow)\
**Post date:** [August 11, 2004, 12:24pm UTC](https://forum.kirupa.com/t/flash-mx-xml-news/119024/4 "2004-08-11T12:24:09Z")

</div>

Anyone able to help? Please

---

<div class="post-metadata">

**Author:** ![RvGaTe](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/rvgate/32/126_2.png) [@RvGaTe](https://forum.kirupa.com/u/RvGaTe)\
**Post date:** [August 11, 2004, 1:13pm UTC](https://forum.kirupa.com/t/flash-mx-xml-news/119024/5 "2004-08-11T13:13:38Z")

</div>

just create an xml file:

news.xml

```auto

<data>
   <news author="someguy" date="11-8-2004" post="BlaBlaBlaBla 1" />
   <news author="someguy" date="11-8-2004" post="BlaBlaBlaBla 2" />
   <news author="someguy" date="11-8-2004" post="BlaBlaBlaBla 3" />
   <news author="someguy" date="11-8-2004" post="BlaBlaBlaBla 4" />
   <news author="someguy" date="11-8-2004" post="BlaBlaBlaBla 5" />
</data>

```

And in flash, you can read this stuff with:

```php

// determine that myXML is in xml format
MyXML = new XML();

// when its loaded:
MyXML.onLoad = function(){
	// get the full news list
	newsList = this.firstChild.childNodes;
	
	// loop trough the news list
	for(i=0;i<newsList.length;i++){
		
		// get an item (including all the data), from the newsList
		newsItem = newsList*;
		
		// make sure it has the news tag
		if(newsItem.nodeName.toLowerCase() == "news"){
			
			// get the info from the Item
			itemAuthor = newsItem.attributes.author;
			itemDate = newsItem.attributes.date;
			itemPost = newsItem.attributes.post
			
			// now do stuff with it :)
			trace("This was posted by "+itemAuthor+" on "+itemDate+".");
			trace(itemPost);
			trace(newline);
		}
	}
}

// load your file, relative or absolute
MyXML.load("news.xml");

```

this should be clear anough…

when you want to do this with php and xml and flash,  
simply rename the loaded file in .php, and generate the same xml format like:

```php

echo "<news author=\"$author\" date=\"$date\" post=\"$post\" />";

```

you can use mysql to get news posts…  
if you have done this, you can get the form in flash to, using loadVariables…

hope that helped you allot

---

<div class="post-metadata">

**Author:** ![fatnslow](https://avatars.discourse-cdn.com/v4/letter/f/7993a0/32.png) [@fatnslow](https://forum.kirupa.com/u/fatnslow)\
**Post date:** [August 11, 2004, 8:59pm UTC](https://forum.kirupa.com/t/flash-mx-xml-news/119024/6 "2004-08-11T20:59:00Z")

</div>

Ok, it helped alot, but I can’t get my text field to display it as it does when it trace.  
Not good with as, but tried something like this:

news = " - “+itemAuthor+” : “+itemDate+” - ";  
news = (itemPost);  
news = (newline);

But then, only one of them displays, so could anyone just correct it?

And, how do I write to the xml? Like I write someguys name in the nameInput and 11-11-11 in the dateInput, and the message in a input. How do I get this to write it to the xml?

Sorry if you got confused

thanks,  
fatnslow

---

<div class="post-metadata">

**Author:** ![fatnslow](https://avatars.discourse-cdn.com/v4/letter/f/7993a0/32.png) [@fatnslow](https://forum.kirupa.com/u/fatnslow)\
**Post date:** [August 12, 2004, 11:02am UTC](https://forum.kirupa.com/t/flash-mx-xml-news/119024/7 "2004-08-12T11:02:51Z")

</div>

Anyone?

Thanks,  
fatnslow

---

<div class="post-metadata">

**Author:** ![RvGaTe](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/rvgate/32/126_2.png) [@RvGaTe](https://forum.kirupa.com/u/RvGaTe)\
**Post date:** [August 12, 2004, 2:59pm UTC](https://forum.kirupa.com/t/flash-mx-xml-news/119024/8 "2004-08-12T14:59:27Z")

</div>

use php and loadVars to send the data to a php script, then let php to do the rest (storing it in a database)

there is an tutorial on kirupa on that one…

---

<div class="post-metadata">

**Author:** ![fatnslow](https://avatars.discourse-cdn.com/v4/letter/f/7993a0/32.png) [@fatnslow](https://forum.kirupa.com/u/fatnslow)\
**Post date:** [August 12, 2004, 6:00pm UTC](https://forum.kirupa.com/t/flash-mx-xml-news/119024/9 "2004-08-12T18:00:50Z")

</div>

OK, ill check it out.

thanks,  
fatnslow

---

<div class="post-metadata">

**Author:** ![fatnslow](https://avatars.discourse-cdn.com/v4/letter/f/7993a0/32.png) [@fatnslow](https://forum.kirupa.com/u/fatnslow)\
**Post date:** [August 12, 2004, 7:16pm UTC](https://forum.kirupa.com/t/flash-mx-xml-news/119024/10 "2004-08-12T19:16:53Z")

</div>

Ok, im not sure wich of the tuts you mean, but isnt it possible to write directly to the xml? and how?  
and how do i show this in a text field: ?  
// now do stuff with it 🙂  
trace (“This was posted by “+itemAuthor+” on “+itemDate+”.”);  
trace (itemPost);  
trace (newline);  
I can only get it to show only one of them.

Just can’t figure it out…

thanks for all the help so far,  
fatnslow

---

<div class="post-metadata">

**Author:** ![fatnslow](https://avatars.discourse-cdn.com/v4/letter/f/7993a0/32.png) [@fatnslow](https://forum.kirupa.com/u/fatnslow)\
**Post date:** [August 13, 2004, 9:14am UTC](https://forum.kirupa.com/t/flash-mx-xml-news/119024/11 "2004-08-13T09:14:24Z")

</div>

Anyone able to help?

---

<div class="post-metadata">

**Author:** ![redanchor](https://avatars.discourse-cdn.com/v4/letter/r/dbc845/32.png) [@redanchor](https://forum.kirupa.com/u/redanchor)\
**Post date:** [August 13, 2004, 9:51am UTC](https://forum.kirupa.com/t/flash-mx-xml-news/119024/12 "2004-08-13T09:51:20Z")

</div>

I know Dulcinea already said this, but, this [http://www.kirupa.com/web/xml\_guestbook.htm](http://www.kirupa.com/web/xml_guestbook.htm) tutorial shows you how to do pretty much exactly what you’re asking.

---

<div class="post-metadata">

**Author:** ![APDesign](https://avatars.discourse-cdn.com/v4/letter/a/e47c2d/32.png) [@APDesign](https://forum.kirupa.com/u/APDesign)\
**Post date:** [August 13, 2004, 9:51am UTC](https://forum.kirupa.com/t/flash-mx-xml-news/119024/13 "2004-08-13T09:51:42Z")

</div>

Make sure the little render html button is selected in the properties box of your dynamic text field. Then try this.

```auto

news = " - "+itemAuthor+" : "+itemDate+" - <br><br>"+itemPost+"<br><br>";

```

basically you can use \<br\> to add spaces. If two \<br\>'s is too much, remove one… if it’s not enough, add one! hope that helps.

---

<div class="post-metadata">

**Author:** ![fatnslow](https://avatars.discourse-cdn.com/v4/letter/f/7993a0/32.png) [@fatnslow](https://forum.kirupa.com/u/fatnslow)\
**Post date:** [August 13, 2004, 2:47pm UTC](https://forum.kirupa.com/t/flash-mx-xml-news/119024/14 "2004-08-13T14:47:18Z")

</div>

Ok, think I’m not so far from getting it. But how do I get this line :

```auto

this.firstChild.childNodes*.firstChild.firstChild.nodeValue

```

to point at the myHeadline text instead of myText in this xml? :

```auto

<guestbook>
	<entry myName="Simen" myDate="13.08.2004">
		 <myText>Bla bla bla bla.</myText>
		 <myHeadline>Ny Lay-out! </myHeadline>
	</entry>
</guestbook>

```

and this line to point at myDate instead of myName: ?

```auto

this.firstChild.childNodes*.attributes.myName

```

Thanks for any help,  
fatnslow

---

<div class="post-metadata">

**Author:** ![fatnslow](https://avatars.discourse-cdn.com/v4/letter/f/7993a0/32.png) [@fatnslow](https://forum.kirupa.com/u/fatnslow)\
**Post date:** [August 13, 2004, 10:22pm UTC](https://forum.kirupa.com/t/flash-mx-xml-news/119024/15 "2004-08-13T22:22:28Z")

</div>

Anyone able to help again?

thanks,  
fatnslow

---

<div class="post-metadata">

**Author:** ![fatnslow](https://avatars.discourse-cdn.com/v4/letter/f/7993a0/32.png) [@fatnslow](https://forum.kirupa.com/u/fatnslow)\
**Post date:** [August 14, 2004, 7:43pm UTC](https://forum.kirupa.com/t/flash-mx-xml-news/119024/16 "2004-08-14T19:43:26Z")

</div>

Anyone able to help again??

Thanks,  
fatnslow

---

<div class="post-metadata">

**Author:** ![fatnslow](https://avatars.discourse-cdn.com/v4/letter/f/7993a0/32.png) [@fatnslow](https://forum.kirupa.com/u/fatnslow)\
**Post date:** [August 15, 2004, 9:38pm UTC](https://forum.kirupa.com/t/flash-mx-xml-news/119024/17 "2004-08-15T21:38:40Z")

</div>

Anyone able to help on the post over?

Thanks,  
fatnslow

---

<div class="post-metadata">

**Author:** ![b\_rich](https://avatars.discourse-cdn.com/v4/letter/b/53a042/32.png) [@b\_rich](https://forum.kirupa.com/u/b_rich)\
**Post date:** [August 15, 2004, 9:49pm UTC](https://forum.kirupa.com/t/flash-mx-xml-news/119024/18 "2004-08-15T21:49:19Z")

</div>

this is a complete guess because you havent showed us your code for the loop but:

this.firstChild.childNodes\*.childNodes[1].firstChild.nodeValue

---

<div class="post-metadata">

**Author:** ![fatnslow](https://avatars.discourse-cdn.com/v4/letter/f/7993a0/32.png) [@fatnslow](https://forum.kirupa.com/u/fatnslow)\
**Post date:** [August 15, 2004, 9:55pm UTC](https://forum.kirupa.com/t/flash-mx-xml-news/119024/19 "2004-08-15T21:55:37Z")

</div>

Thanks! It was correct. But could you just explain it? or an web site wich makes things clearer?

Thanks,  
fatnslow

---

<div class="post-metadata">

**Author:** ![b\_rich](https://avatars.discourse-cdn.com/v4/letter/b/53a042/32.png) [@b\_rich](https://forum.kirupa.com/u/b_rich)\
**Post date:** [August 15, 2004, 11:13pm UTC](https://forum.kirupa.com/t/flash-mx-xml-news/119024/20 "2004-08-15T23:13:57Z")

</div>

Your at the website my friend, kirupa himself wrote a great tutorial on displaying txt w/xml. Senocular ([http://www.senocular.com](http://www.senocular.com)) has written like 4-5 tutorials which are also all here on kirupa. Just search around. At the begining of each forum check the threads that say “resources”.

as for the code i posted for you…

**this.firstChild.childNodes** \*.childNodes[1].firstChild.nodeValue  
This part loops through your xml file and finds the first node which in your case is “entry”

this.firstChild.childNodes\*.**childNodes[1]**.firstChild.nodeValue  
This part points to your second set of nodes within “entry” even though it says 1 its actually the second so if you wanted to point to “myText” it would be a 0.

Forgive me if i explained this wrong, i too am just learning like you. I really would suggest just reading everything you can get your hands on and practice practice practice.

And now for the new question you added to your post:

> and this line to point at myDate instead of myName: ?  
> Code:

this.firstChild.childNodes\*.attributes.myName

change myName to myDate… thats it 🙂

Hope this helps a lil.
