-
[RESOLVED] XML Problems
hi every1
just a quick little question it has more than likely been answered 100s of times before i am new to XML i am trying to create a flash site that retrives all the text from a single XML document. i need to know how i can format the text eg BOLD ITALIC and UNDERLINE within my XML document i also need to know how i can use the <br> tag for new line in my XML
is this possiable below is the coding i am using already
This coding is in my 1st frame of my Flash Movie to store the XML in arrays so it can be recalled within the movie
PHP Code:
stop ();
setProperty("", _quality, "BEST");
var x:XML = new XML();
x.ignoreWhite = true;
x.load("illitsolutions.xml");
var menu:Array = new Array();
var messages:Array = new Array();
var Homepage:Array = new Array();
var Aboutus:Array = new Array();
var Services:Array = new Array();
var Testimonials:Array = new Array();
var Page5:Array = new Array();
var Contactus:Array = new Array();
x.onLoad = function() {
var rootNode = this.firstChild;
var menuNode = rootNode.firstChild;
var msgNode = menuNode.nextSibling;
var pagesNode = msgNode.nextSibling;
var homeNode = pagesNode.firstChild;
var aboutNode = homeNode.nextSibling;
var servicesNode = aboutNode.nextSibling;
var testimonialNode = servicesNode.nextSibling;
var page5Node = testimonialNode.nextSibling;
var contactNode = page5Node.nextSibling;
var menuItems:Array = menuNode.childNodes;
var messagesItems:Array = msgNode.childNodes;
var homepageItems:Array = homeNode.childNodes;
var aboutusItems:Array = aboutNode.childNodes;
var servicesItems:Array = servicesNode.childNodes;
var testimonialsItems:Array = testimonialNode.childNodes;
var page5Items:Array = page5Node.childNodes;
var contactItems:Array = contactNode.childNodes;
for(i=0; i<menuItems.length; i++){
var tmpArray:Array = new Array();
tmpArray.push(menuItems[i].attributes.id, menuItems[i].attributes.title);
menu.push(tmpArray);
}
for(i=0; i<messagesItems.length; i++){
var tmpArray:Array = new Array();
tmpArray.push(messagesItems[i].attributes.id, messagesItems[i].attributes.text);
messages.push(tmpArray);
}
for(i=0; i<homepageItems.length; i++){
var tmpArray:Array = new Array();
tmpArray.push(homepageItems[i].attributes.id, homepageItems[i].attributes.text);
Homepage.push(tmpArray);
}
for(i=0; i<aboutusItems.length; i++){
var tmpArray:Array = new Array();
tmpArray.push(aboutusItems[i].attributes.id, aboutusItems[i].attributes.text);
Aboutus.push(tmpArray);
}
for(i=0; i<servicesItems.length; i++){
var tmpArray:Array = new Array();
tmpArray.push(servicesItems[i].attributes.id, servicesItems[i].attributes.text);
Services.push(tmpArray);
}
for(i=0; i<testimonialsItems.length; i++){
var tmpArray:Array = new Array();
tmpArray.push(testimonialsItems[i].attributes.id, testimonialsItems[i].attributes.text);
Testimonials.push(tmpArray);
}
for(i=0; i<page5Items.length; i++){
var tmpArray:Array = new Array();
tmpArray.push(page5Items[i].attributes.id, page5Items[i].attributes.text);
Page5.push(tmpArray);
}
for(i=0; i<contactItems.length; i++){
var tmpArray:Array = new Array();
tmpArray.push(contactItems[i].attributes.id, contactItems[i].attributes.text);
Contactus.push(tmpArray);
}
}
this coding is on the different pages that the text will be displayed on
PHP Code:
stop();
for(i=0; i<_root.Homepage.length; i++){
var tmp = _root.Homepage[i][0]
this[tmp].text = _root.Homepage[i][1];
}
any finally this is my XML document i am using
PHP Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<siteconfig>
<menu>
<item id="page1" title="HOMEPAGE" url=""/>
<item id="page2" title="ABOUT US" url=""/>
<item id="page3" title="SERVICES" url=""/>
<item id="page4" title="TESTIMONALS" url=""/>
<item id="page5" title="COMMING SOON" url=""/>
<item id="page6" title="CONTACT US" url=""/>
</menu>
<messages>
<message id="mainFormBox" text="Please fill all fields on the form" />
<message id="contactFail" text="the mail failed to be delivered" />
<message id="contactSent" text="the mail was delivered successfully" />
</messages>
<pages>
<Homepage>
<text id="homeTopLeft" text="home" />
<text id="homeBottomLeft" text="home Text 2" />
<text id="homeMiddleBottom" text="home Text 3" />
<text id="homeTopRight" text="home Title" />
<text id="homeBottomRight" text="home Text 5" />
</Homepage>
<Aboutus>
<text id="aboutusTopLeft" text="About Us" />
<text id="aboutusLeftMiddleTitle" text="Aboutus Middle Title" />
<text id="aboutusBottomLeft" text="Aboutus Text 3" />
<text id="aboutusRightTitle" text="Aboutus Right Title" />
<text id="aboutusTopRight" text="Text 5" />
<text id="aboutusMiddleRight" text="Aboutus Middle Title" />
<text id="aboutusBottomRight" text="Aboutus Text 7" />
</Aboutus>
<Services>
<text id="servicesTopLeftTitle" text="Services" />
<text id="servicesTopLeft" text="Services Text 2" />
<text id="servicesBottomLeft" text="Services Text 3" />
<text id="servicesRight" text="Services Text 5" />
</Services>
<Testimonials>
<text id="testimonialsTopLeft" text="testimonials 1" />
<text id="testimonialsMiddle" text="testimonials 2" />
<text id="testimonialsRight" text="testimonials 3" />
</Testimonials>
<Page5>
<text id="page5TopLeftTitle" text="" />
<text id="page5BottomLeft" text="" />
<text id="page5middle" text="Comming Soon" />
</Page5>
<Contactus>
<text id="contactustoptitle" text="ContactUs" />
<text id="contactustoptext" text="Contactus Text 2" />
<text id="contactLeft" text="ContactLeft Text" />
<text id="contactRight" text= <![CDATA[<P ALIGN='CENTER'><B><FONT color='#FF0000'>Telephone: E-mail: Fax: </a></FONT></P>]]>
</Contactus>
</pages>
</siteconfig>
as you can see i have tried using the CDATA tag within XML but it does not seem to be working
Many thanks for any help in advance
LeeWalker87
-
FK'n_dog
far too much info there
to simplify, test this with a new fla and xml file -
PHP Code:
// on stage - textfield - instance name - testField
_xml = new XML();
_xml.ignoreWhite = true;
_xml.load("cdata.xml");
_xml.onLoad = function(){
testField.html = true;
testField.htmlText = this.firstChild.firstChild.nodeValue;
};
/*--cdata.xml--
<?xml version="1.0" encoding="UTF-8"?>
<text>
<![CDATA[<P ALIGN='CENTER'><B><FONT color='#FF0000'><BR>Telephone:<BR> E-mail:<BR> Fax: </a></FONT></P>]]>
</text>
*/
test, then modify your files to suit
-
is there anyway in which i can use my current layout of XML file do do this
-
FK'n_dog
As I understand from the XML 1.0 spec,
attribute value is a kind of a literal which cannot start with ...<...
So, the answer is "no".
-
sorry for sounding very silly i am very new to XML so i would need to rewrite my Flash coding as well as my XML file
the coding i have in flash is as listed above in the 1st message
-
FK'n_dog
you wil have to refer to the cdata section as nodeValue not attributes
see my test file post above
-
i am a little confused at the moment the code i have is
for(i=0; i<contactItems.length; i++){
var tmpArray:Array = new Array();
tmpArray.push(contactItems[i].attributes.id, contactItems[i].attributes.text);
Contactus.push(tmpArray);
}
is this the code that needs changing or is it the one that calls to array
for(i=0; i<_root.Contactus.length; i++){
var tmp = _root.Contactus[i][0]
this[tmp].text = _root.Contactus[i][1];
-
FK'n_dog
to save a huge re-write, keep xml and flash code as/is (scrap cdata in xml)
when outputting data to textfield, set the textfield.html property to true
and use my_txt.htmlText = "<b>"+array[id][1]+"</b>"
make use of trace and/or List Variables to view the array content
hth
-
i am new to XML and flash as i said i am a little confused with what u mean the only reason i got so far with this site is i did it at college but i have now left and tryin 2 edit it would the sugested not only give me bold text
-
FK'n_dog
edit xml and make 'phone, mail, fax as separate attributes
add these new attributes to your Flash contact array code
you can then set html tags to each element of your contact array
-
i have started the re write so that it uses nodes and not attributes for the whole site and not just the contact array i have change the coding to the following
for(i=0; i<contactItems.length; i++){
var tmpArray:Array = new Array();
tmpArray.push(TestField.htmlText = contactNode.nodeValue);
menu.push(tmpArray);
}
this is the for loop coding on my 1st frame of the movie and my XML now looks like this
<?xml version="1.0" encoding="ISO-8859-1"?>
<siteconfig>
<Contactus>
<text>
<id>"contactustoptitle</ id>
<location>text title</ location>
<text>1</ text>
</ text>
<text>
<id>"contactustoptext/ id>
<location>text toptext</ location>
<text>2</ text>
</ text>
<text>
<id>"contactusleft</ id>
<location>textleft</ location>
<text>3</ text>
</ text>
<text>
<id>"contactusright</ id>
<location>textbottom</ location>
<text>4</ text>
</ text>
</ Contactus>
</ siteconfig>
i just have to rewrite this for loop which is on every page callin the text arrays to the correct page
for(i=0; i<_root.Contactus.length; i++){
var tmp = _root.Contactus[i][0]
this[tmp].text = _root.Contactus[i][1];
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|