# CMS help. XML instead of TXT

**URL:** <https://forum.kirupa.com/t/cms-help-xml-instead-of-txt/185840>\
**Category:** flash\
**Created:** [April 17, 2006, 1:21am UTC](https://forum.kirupa.com/t/cms-help-xml-instead-of-txt/185840 "2006-04-17T01:21:19Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Asparagus](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@Asparagus](https://forum.kirupa.com/u/Asparagus)\
**Post date:** [April 17, 2006, 1:21am UTC](https://forum.kirupa.com/t/cms-help-xml-instead-of-txt/185840/1 "2006-04-17T01:21:19Z")

</div>

I stubbled across a nice little CMS-type thing which updates an external .txt file. I was wondering if some kind soul knew if it were possible to change the coding so one could edit/update/manage .xml files instead?

Here is a link to the full code, a tutorial, demos and source files: [http://ntdesigns.net/tutorial/NewsManager.html](http://ntdesigns.net/tutorial/NewsManager.html)

Many many thanx in advance for anyone that can help me out.

---

<div class="post-metadata">

**Author:** ![Asparagus](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@Asparagus](https://forum.kirupa.com/u/Asparagus)\
**Post date:** [April 17, 2006, 3:31pm UTC](https://forum.kirupa.com/t/cms-help-xml-instead-of-txt/185840/2 "2006-04-17T15:31:40Z")

</div>

Anybody? Nobody? Kirupaaaa! ☹

---

<div class="post-metadata">

**Author:** ![bootiteq](https://avatars.discourse-cdn.com/v4/letter/b/eb9ed0/32.png) [@bootiteq](https://forum.kirupa.com/u/bootiteq)\
**Post date:** [April 17, 2006, 10:42pm UTC](https://forum.kirupa.com/t/cms-help-xml-instead-of-txt/185840/3 "2006-04-17T22:42:43Z")

</div>

ive been wanting to do the same thing Asparagus.

i probably wont get a chance to have a proper look till friday. but i’ll see if i can come up with something similar.

:}

---

<div class="post-metadata">

**Author:** ![bootiteq](https://avatars.discourse-cdn.com/v4/letter/b/eb9ed0/32.png) [@bootiteq](https://forum.kirupa.com/u/bootiteq)\
**Post date:** [April 18, 2006, 7:38am UTC](https://forum.kirupa.com/t/cms-help-xml-instead-of-txt/185840/4 "2006-04-18T07:38:51Z")

</div>

Are you after a single entry like that example or multiple entries?

If you want multiple entries I cant help much… well not yet anyway.

---

<div class="post-metadata">

**Author:** ![bootiteq](https://avatars.discourse-cdn.com/v4/letter/b/eb9ed0/32.png) [@bootiteq](https://forum.kirupa.com/u/bootiteq)\
**Post date:** [April 18, 2006, 10:54am UTC](https://forum.kirupa.com/t/cms-help-xml-instead-of-txt/185840/5 "2006-04-18T10:54:22Z")

</div>

ho k,  
I got a single entry version working. Ive only spent half an hour on it. hopefully it works for too.

EDIT: FOUND SOME ISSUES

i renamed this file to “newsSaver\_xml2.php”

```php

<?
$myFileName=$_POST["myFileName"]; 
$title=$_POST["title"]; 
$article=$_POST["article"];

if(ereg("/","$myFileName") || ereg('.php',"$myFileName")) 
die("Thou shall not hack!");  

$xml_output = "<?xml version=\"1.0\"?>
\r";
$xml_output .= "<entries>
";
$xml_output .= "	<title><![CDATA[" . $title . "]]>
";
$xml_output .= "	</title>
";
$xml_output .= "	<entry><![CDATA[" . $article . "]]>
";
$xml_output .= "	</entry>
";
$xml_output .= "</entries>";

$fp = fopen ("$myFileName", "w+");
fwrite($fp,$xml_output); 
//fwrite($fp,"$article"); 
fclose($fp); 

if ($fp) { 
echo ("&msg=Save Successful!&name=$name&myTextSave=$myTextSave");   
} else { 
echo ("&error=OK&msg=Save unsuccessful!...an error occurred!"); 
} 
 
?> 

```

newsReaderAdmin.fla replace all code on frame 1 with this check html enabled of main text box

```auto

stop();
//Create the loadVars object to hold the data
container = new LoadVars();
//Create a variable to hold the file name for the data to be saved
container.myFileName = "saveAndLoad.xml";
container.myFilePath = "http://yourpath/";

blog_xml = new XML();
blog_xml.ignoreWhite = true;
blog_xml.onLoad = function(success) {
	if (!success) {
		trace("Failed to load");
		_root.article.htmlText = "Failed to load. Please try again.";
	} else {
		trace("Data is loaded");
		blog = this.firstChild.childNodes;
		//populate the textfields with the container data
		_root.title.htmlText = unescape(blog[0].childNodes);
		_root.article.htmlText = unescape(blog[1].childNodes);
		trace(blog[0].childNodes);
		_root.msg.text = _root.container.msg;
	}
};
blog_xml.load("http://yourpath/saveAndLoad.xml");

//Button event to update the textfile and NewsReader movie
myButton.onRelease = function() {
	
	container.title = escape(_root.title.htmlText);
	container.article = escape(_root.article.htmlText);
	//call the PHP script to write the data to the textfile
	container.sendAndLoad("http://yourpath/newsSaver_xml2.php", _root.container, POST);
	//create a local connection to the NewsReader movie to update it real time
	myLocalConnection = new LocalConnection();
	//send the updated data
	myLocalConnection.send("incoming message", "onReceive1");
	//close the connection
	myLocalConnection.close();
	//custom function to clear the return message from the PHP script
	myInterval=setInterval(myLoad, 4000);
	//repopulate the container data
	container.load("http://yourpath/saveAndLoad.xml");
_root.nextFrame();
}
//Custom function to clear msg textfield
myLoad = function () {
	_root.msg.text = "";
	clearInterval(myInterval);	
}

```

newsReader.fla  
replace current code on frame 1 with this. Make sure both text boxes are html enabled

```auto

blog_xml = new XML();
blog_xml.ignoreWhite = true;
blog_xml.onLoad = function(success) {
	if (!success) {
		trace("Failed to load");
		_root.article.htmlText = "Failed to load. Please try again.";
	} else {
		trace("Data is loaded");
		blog = this.firstChild.childNodes;
		//populate the textfields with the container data
		_root.title.html = true;
		_root.article.html = true;
		_root.title.htmlText = unescape(blog[0].childNodes);
		_root.article.htmlText = unescape(blog[1].childNodes);
		trace(unescape(blog[0].childNodes));
	}
};
blog_xml.load("http://yourpath/saveAndLoad.xml");

//Create the local connection object for the admin movie
myLocalConnection = new LocalConnection();
//When the connection call is recieved, repopulate the loadVars object
myLocalConnection.onReceive1 = function() {
	//Set a delay interval to allow time for the data to 
	//be updated before loading.
	myInterval=setInterval(myLoad,1000);
}
//Listen for the local connection from the admin movie
myLocalConnection.connect("incoming Message");

```

will have another look later, hopefully this helps.  
:rocker:

---

<div class="post-metadata">

**Author:** ![bootiteq](https://avatars.discourse-cdn.com/v4/letter/b/eb9ed0/32.png) [@bootiteq](https://forum.kirupa.com/u/bootiteq)\
**Post date:** [April 18, 2006, 10:56am UTC](https://forum.kirupa.com/t/cms-help-xml-instead-of-txt/185840/6 "2006-04-18T10:56:50Z")

</div>

almost forgot…

php file now spits xml out like this…

saveAndLoad.xml

EDIT: Have changed the tree structure to this…

```auto

<?xml version="1.0"?>

<entries>
	<title><![CDATA[%3Cb%3Etitle%20text%3C%2Fb%3E]]>
	</title>
	<entry><![CDATA[body%20text]]>
	</entry>
</entries>

```

you may need to save this into your directory  
:moustache

---

<div class="post-metadata">

**Author:** ![Asparagus](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@Asparagus](https://forum.kirupa.com/u/Asparagus)\
**Post date:** [April 18, 2006, 9:22pm UTC](https://forum.kirupa.com/t/cms-help-xml-instead-of-txt/185840/7 "2006-04-18T21:22:58Z")

</div>

Absolutely brilliant! Next time I’m in Melbourne, I’ll buy ya a beer.  
Now that’s said, I’m going to start getting greedy.

I use XML from my external text instead of basic TXT because I have found a nice way of implimenting stylesheets to the text. Just basic stuff: style, rollover links, headings, etc.

Is there any way to anable this? Here’s the actionscript I’ve used in the past:

```auto
//init TextArea component
myText.html = true; myText.wordWrap = true; myText.multiline = true; myText.label.condenseWhite=true;
/ *****load css***** /
Style = new TextField.StyleSheet(); Style.load("stylesheet.css"); myText.styleSheet = Style;
/ *****load in XML***** /
Content = new XML(); Content.ignoreWhite = true; Content.load("news.xml"); Content.onLoad = function(success) {if(success) {myText.text = Content;}}

```

I’ve tried just plopping the ‘load css’ script in, but to no avail…

Many thanx for any help given.

---

<div class="post-metadata">

**Author:** ![treatkor](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/treatkor/32/680_2.png) [@treatkor](https://forum.kirupa.com/u/treatkor)\
**Post date:** [April 18, 2006, 10:09pm UTC](https://forum.kirupa.com/t/cms-help-xml-instead-of-txt/185840/8 "2006-04-18T22:09:55Z")

</div>

maybe your stylesheet isn’t being loaded before it’s being assigned. try using an onLoad function (the same as you’ve done with Content.onLoad) to check if the css is loaded before assigning it to your textfield. something like this:

```auto

myText.html = true;
myText.wordWrap = true;
myText.multiline = true;
myText.label.condenseWhite=true;
Content = new XML();
Content.ignoreWhite = true;

Content.onLoad = function(success) {
if(success) {
// If the xml loaded without error,
// assign it text field
trace("xml loaded");
myText.htmlText = Content;}
}

Style.onLoad = function(success) {
if (success) {
// If the style sheet loaded without error,
// assign it to the text object
trace("stylesheet loaded");
myText.styleSheet = Style;
// now load the xml
Content.load("news.xml");
} else {
trace("ERROR loading stylesheet");
}

};

Style.load("stylesheet.css"); /*starts everything off*/

```

hope that helps,  
🙂

---

<div class="post-metadata">

**Author:** ![Asparagus](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@Asparagus](https://forum.kirupa.com/u/Asparagus)\
**Post date:** [April 18, 2006, 10:29pm UTC](https://forum.kirupa.com/t/cms-help-xml-instead-of-txt/185840/9 "2006-04-18T22:29:10Z")

</div>

Thanx for trying, treatkor, but it didn’t seem to make a difference.

On a side note, I’ve been looking around at Flash text editors, and thought about Frankensteining it with this little gadget we’re making here, to make a nifty little writer/converter/CMS for Flash.

If it ever comes alive, I’ll post it.

---

<div class="post-metadata">

**Author:** ![treatkor](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/treatkor/32/680_2.png) [@treatkor](https://forum.kirupa.com/u/treatkor)\
**Post date:** [April 18, 2006, 10:48pm UTC](https://forum.kirupa.com/t/cms-help-xml-instead-of-txt/185840/10 "2006-04-18T22:48:07Z")

</div>

myText.html = true;  
myText.wordWrap = true;  
myText.multiline = true;  
myText.label.condenseWhite = true;  
myContent = new XML();  
myContent.ignoreWhite = true;  
myStyle = new TextField.StyleSheet(); //i forgot this line before  
myContent.onLoad = function(success) {  
trace(“myContent functioncalled”);  
if (success) {  
// If the xml loaded without error,  
// assign it to the text field  
trace(“xml loaded”);  
myText.htmlText = myContent;  
}  
};  
myStyle.onLoad = function(success) {  
trace(“myStyle function called”);  
if (success) {  
// If the style sheet loaded without error,  
// assign it to the text object  
trace(“stylesheet loaded”);  
myText.styleSheet = myStyle;  
// now load the xml  
myContent.load(“news.xml”);  
} else {  
trace(“ERROR loading stylesheet”);  
}  
};  
myStyle.load(“stylesheet.css”);  
/_starts everything off_/  
stop();

---

<div class="post-metadata">

**Author:** ![Asparagus](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@Asparagus](https://forum.kirupa.com/u/Asparagus)\
**Post date:** [April 18, 2006, 11:47pm UTC](https://forum.kirupa.com/t/cms-help-xml-instead-of-txt/185840/11 "2006-04-18T23:47:22Z")

</div>

i just realised that the xml text file has to start and end with \<body\> tags for the CSS to work. how can i replace the \<title\>\<entry\> tags?

---

<div class="post-metadata">

**Author:** ![bootiteq](https://avatars.discourse-cdn.com/v4/letter/b/eb9ed0/32.png) [@bootiteq](https://forum.kirupa.com/u/bootiteq)\
**Post date:** [April 19, 2006, 1:43am UTC](https://forum.kirupa.com/t/cms-help-xml-instead-of-txt/185840/12 "2006-04-19T01:43:57Z")

</div>

I had another look at what i did last night, and im not convinced I have done this the best way…

I dont have a chance to check it right now but may get a chance later.

I have a feeling I may not need to escape characters when using \<!CDATA[]]\>

either that or I dont need to use \<!CDATA[]]\> as I have escaped (ie. url encoded characters)

not sure though…will check again later.

Problems arose when I tryed to use html tags with the above code I showed you.

truth is I only use xml for text that needs columns and use normal .txt like the original CMS does whenever I need html styling.

would be good to figure out how to do all of this with xml.  
more soon…

😠

---

<div class="post-metadata">

**Author:** ![Asparagus](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@Asparagus](https://forum.kirupa.com/u/Asparagus)\
**Post date:** [April 19, 2006, 2:52am UTC](https://forum.kirupa.com/t/cms-help-xml-instead-of-txt/185840/13 "2006-04-19T02:52:10Z")

</div>

[http://www.asparagusproductions.com/cms/xml/xml\_cms\_with\_css.zip](http://www.asparagusproductions.com/cms/xml/xml_cms_with_css.zip) 296kb/.zip

Here’s what I have so far. I’ve messed around with the lot and renamed stuff. I think it’s the CMS\_saver.php file that needs fiddling with to remove the \<title\>\<entry\> tags and replace them with \<body\> tags.

At this point, it’s working, just without CSS.

And if any genious can figure out how to intergrate it with a Rich Text Editor, then we may just have something quite snazzy.

---

<div class="post-metadata">

**Author:** ![bootiteq](https://avatars.discourse-cdn.com/v4/letter/b/eb9ed0/32.png) [@bootiteq](https://forum.kirupa.com/u/bootiteq)\
**Post date:** [April 19, 2006, 11:13am UTC](https://forum.kirupa.com/t/cms-help-xml-instead-of-txt/185840/14 "2006-04-19T11:13:39Z")

</div>

I load css much like Treaktor does. ie… ensure css is loaded then load/set text. Strange that it doesnt work for you.

> [@Asparagus](#):
>
> i just realised that the xml text file has to start and end with \<body\> tags for the CSS to work. how can i replace the \<title\>\<entry\> tags?

im presuming you have a style named ‘body’

if you are doing something like this that is…

> **[DEWA89 | LINK ALT DAFTAR DAN LOGIN VPN89.ME/DEWA89](https://89decibeles.com/)**
>
> DEWA89 adalah game gacor maxwin dari tahun 2022 sekaligus agen provider pragmatic play dan pg soft terpercaya yang menawarkan deposit via qris.

if this is the case. Change the names in the php file to suit. Change ‘title’ or ‘entry’ to ‘body’. Make sure you do it for both the opening and closing tags

eg:

```php
<?
$myFileName=$_POST["myFileName"]; 
$title=$_POST["title"]; 
$article=$_POST["article"];

if(ereg("/","$myFileName") || ereg('.php',"$myFileName")) 
die("Thou shall not hack!");  

$xml_output = "<?xml version=\"1.0\"?>
\r";
$xml_output .= "<entries>
";

/*
$xml_output .= "	<title><![CDATA[" . $title . "]]>
";
$xml_output .= "	</title>
";
*/
$xml_output .= "	<body><![CDATA[" . $title . "]]>
";
$xml_output .= "	</body>
";

$xml_output .= "	<entry><![CDATA[" . $article . "]]>
";
$xml_output .= "	</entry>
";
$xml_output .= "</entries>";

$fp = fopen ("$myFileName", "w+");
fwrite($fp,$xml_output); 
//fwrite($fp,"$article"); 
fclose($fp); 

if ($fp) { 
echo ("&msg=Save Successful!&name=$name&myTextSave=$myTextSave");   
} else { 
echo ("&error=OK&msg=Save unsuccessful!...an error occurred!"); 
} 
 
?> 

```

Im giving up on this particular flash example. I want a text editor like this kirupa one (as it seems you do too). Something with bold, italics, links, colour and size at least.  
Im gonna try downloading a free php forum and figure out how to extract what i need.

I’ll let you know how I get on  
:vamp:

---

<div class="post-metadata">

**Author:** ![bootiteq](https://avatars.discourse-cdn.com/v4/letter/b/eb9ed0/32.png) [@bootiteq](https://forum.kirupa.com/u/bootiteq)\
**Post date:** [April 22, 2006, 1:56am UTC](https://forum.kirupa.com/t/cms-help-xml-instead-of-txt/185840/15 "2006-04-22T01:56:28Z")

</div>

had a wee look at a rich text editor which i now know is called a WYSIWYG editor.

pretty fine really. found a few here [http://www.htmlarea.com](http://www.htmlarea.com)

Ive been pulling apart this one  
[http://www.unverse.net/whizzywig-cross-browser-html-editor.html](http://www.unverse.net/whizzywig-cross-browser-html-editor.html)

it likes to change \<b\> tags to \<strong\> and changes \<font color\> tags to inline styles but so far it seems pretty easy to change it to suit flash.

have yourself a looky  
:bandit:
