Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HTML stored in an XML file

Status
Not open for further replies.

seantuk

Programmer
Mar 22, 2005
62
0
0
GB
the content for a site i'm building is stored in xml files, so that it can be used for the no script/flash version of the site, and the full version. the xml file looks like this:

Code:
<?xml version="1.0" encoding="iso-8859-1"?>
<siteContent id="tester">
	<html id="sample">
		some text
	</html>
	<html id="sample2">
		some <i>other</i> text
	</html>
</siteContent>

the no script version works through aspx, and is lovelly. the flash version looks like this:

Code:
stop();

var epDoc:XML = new XML();
epDoc.ignoreWhite = true;
epDoc.load(pageName + ".xml");

epDoc.onLoad = function(success)
{
    if(success)
    {
        var matter:Hashtable = new Hashtable;
		
		for(var i:Number=0; i<int(this.childNodes[0].childNodes.length); i++)
        {
            matter.addItem(this.childNodes[0].childNodes[i].attributes.id, this.childNodes[0].childNodes[i].firstChild);
			}
		
		trace("SAMPLE2: " + matter.getItem("sample2"));
        _root.play();
    }
}


hashtable is my own class, it's self explanitory (just assume it works, 'cos it does). the trace output ii'm getting is this:

Code:
SAMPLE: 
		some


what do i need to do to get the entire content from the xml file, instead if it cropping at the '<' character?
 
come on guys, there must be somebody here who knows how to use flash's xml utilities to read characters like '<' and '>' from xml files
 
You have to escape [tt]<i>[/tt] using [tt]&lt;i&gt;[/tt], otherwise it will be treated as an XML node.

Also in your script, [tt]this.childNodes[0].childNodes.firstChild[/tt] needs to be [tt] this.childNodes[0].childNodes.firstChild.nodeValue[/tt], if you want to get the value of the text node.

Kenneth Kawamoto
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top