-
Question about displaying childNodes in different textareas
Hey guys!
I'm new to the community!
I was wondering, I an have this XML file thats set up in this style:
Code:
<?xml version="1.0" encoding="UTF-8" ?>
<profile>
<id>18771967</id>
<name></name>
</profile>
I would like to have each childNode (i.e. <name>) go into a separate dynamic text area. How would I do this?
-
FK'n_dog
PHP Code:
//--on stage--
//--dynamic textfields, instance names id,name0,name1,name2
txtArr = [id,name0,name1,name2]; // add instance names to the array
_xml = new XML();
_xml.ignoreWhite = true;
_xml.load("xmltest.xml");
_xml.onLoad = function(){
aNode = this.firstChild.childNodes;
len = aNode.length;
for(var n=0;n!=len;n++){
trace(aNode[n].firstChild);
txtArr[n].text = aNode[n].firstChild;
}
};
/*--test.xml--
<?xml version="1.0" encoding="UTF-8" ?>
<profile>
<id>18771967</id>
<name>Ann</name>
<name>Bob</name>
<name>Cyd</name>
</profile>
*/
hth
-
thanks!
So if i had more childnodes in the XML file i could just add dynamic text boxes with different instance names and it would load them in??
and add them into :
Code:
txtArr = [id,name0,name1,name2,lastlogin, info]; // add instance names to the array
?? I really appreciate it
Originally Posted by a_modified_dog
PHP Code:
//--on stage--
//--dynamic textfields, instance names id,name0,name1,name2
txtArr = [id,name0,name1,name2]; // add instance names to the array
_xml = new XML();
_xml.ignoreWhite = true;
_xml.load("xmltest.xml");
_xml.onLoad = function(){
aNode = this.firstChild.childNodes;
len = aNode.length;
for(var n=0;n!=len;n++){
trace(aNode[n].firstChild);
txtArr[n].text = aNode[n].firstChild;
}
};
/*--test.xml--
<?xml version="1.0" encoding="UTF-8" ?>
<profile>
<id>18771967</id>
<name>Ann</name>
<name>Bob</name>
<name>Cyd</name>
</profile>
*/
hth
-
FK'n_dog
yes, match the number of textfields in the array
to the number of nodes in the xml file
-
Thanks so much!
Originally Posted by a_modified_dog
yes, match the number of textfields in the array
to the number of nodes in the xml file
-
Hey i'm having trouble with loading HTML formatted XML into the textareas. Changing
PHP Code:
txtArr[n].txt = aNode[n].firstChild;
to
PHP Code:
txtArr[n].htmlText = aNode[n].firstChild;
formats some of the text and loads it properly but some of it still loads like it written in the xml file :[
Any idea how to fix it?
The acutal XML Files is this
PHP Code:
<?xml version="1.0" encoding="UTF-8" ?>
- <profile>
<id>18771967</id>
<fullname>73c%7C%26trade%3B+%3D+%5BTed%2C+Teddy%2C+Theo%2C+Theodore.+wtf%21%5D</fullname>
<address>url</address>
<profilephoto>http://b2.ac-images.myspacecdn.com/00773/28/20/773890282_m.jpg</profilephoto>
<headline>lol</headline>
<lastlogin>11/7/2007</lastlogin>
<gender>Male</gender>
<age>16 years old</age>
<town>Good+ol%27+127.0.0.1</town>
<country>United+States</country>
<interests>-</interests>
<music>-</music>
<films>%3Cdiv+style%3D%22display%3Anone%3B%22%3E%3C%2Fdiv%3E</films>
<television>%3Cdiv+style%3D%22display%3Anone%3B%22%3E%3C%2Fdiv%3E</television>
<books>%3Cdiv+style%3D%22display%3Anone%3B%22%3E%3C%2Fdiv%3E</books>
<heroes>%3Cdiv+style%3D%22display%3Anone%3B%22%3E%3C%2Fdiv%3E</heroes>
<aboutme>ey-o</aboutme>
<whotomeet>ey-o</whotomeet>
<mystatus>Single</mystatus>
<herefor>Networking, Friends</herefor>
<myorientation>Straight</myorientation>
<hometown>Good+ol%27+127.0.0.1</hometown>
<bodytype>5' 11" / Slim / Slender</bodytype>
<ethnicity>White / Caucasian</ethnicity>
<religion>N/a</religion>
<zodiacsign>Pisces</zodiacsign>
<smokedrink>N/a</smokedrink>
<children>Someday</children>
<education>High school</education>
<occupation>McDonalds+Crew+Trainer</occupation>
<income>Less than $30,000</income>
<layout>http://members.cox.net/tass2001/tech5.swf</layout>
</profile>
&& Yes its for myspace
Last edited by tass2001; 11-18-2007 at 08:13 PM.
-
Okay i figured out what I need is to add the unescape function to some of the textboxes, how would I do that?
-
FK'n_dog
something like this ??
str = aNode[n].firstChild;
str = unescape(str);
txtArr[n].htmlText = str;
-
Originally Posted by a_modified_dog
something like this ??
str = aNode[n].firstChild;
str = unescape(str);
txtArr[n].htmlText = str;
! Yes!
-
Okay I'm sorry one more problem i'm having, some of the text boxes are going inside movie clips and when i load the movie they appear empty. How would I tell flash that these text boxes are inside movie clips so it will load the information into them?
-
FK'n_dog
you'll have to use a different approach -
PHP Code:
_xml = new XML();
_xml.ignoreWhite = true;
_xml.load("xmltest.xml");
arr = []; // create an array
_xml.onLoad = function(){
aNode = this.firstChild.childNodes;
len = aNode.length;
for(var n=0;n!=len;n++){
arr[n] = aNode[n].firstChild; // load the array
}
populateText(); // xml is loaded, array is loaded, populate the textfields
};
function populateText(){
_root.field1.text = arr[0]; // textfield on root
_root.clip1.field2.text = arr[1]; // textfield in movieclip
_root.clip2.clip2a.field3.text = arr[2]; // textfield in nested movieclip
};
use Test Movie / List Variables to view the array
-
-
FK'n_dog
add a frame action to 2nd keyframe of movieclip -
field1.text = _root.arr[3];
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
|