-
Senior Member
Help me with the correct syntax please.
Hi,
I can't get this right. What am I doing wrong? Any help is much appreciated!
Thanks,
/Flip
XML
Code:
<?xml version="1.0" encoding="utf-8" ?>
<port>
<set>
<image piece="imgA1.jpg" />
<image piece="imgA2.jpg" />
</set>
</port>
<port>
<set>
<image piece="imgB1.jpg" />
<image piece="imgB2.jpg" />
</set>
</port>
AS
PHP Code:
xmlParse = function (xmlObj) {
aNode = xmlObj.childNodes;
len1 = aNode.length;
for (var n = 0; n != len1; n++) {
piece[n] = [];
len2 = aNode[n].firstChild.childNodes.length;
for (var j = 0; j != len2; j++) {
piece[n][j] = aNode[n].firstChild.childNodes[j].attributes.piece;
}
}
trace(piece[1][1]); // traces undefined
}
Last edited by flipsideguy; 07-01-2008 at 04:43 PM.
Flipsideguy
-
FK'n_dog
tests OK here using -
PHP Code:
_xml = new XML();
_xml.ignoreWhite = true;
_xml.load("test.xml");
piece = [];
_xml.onLoad = function () {
aNode = this.childNodes;
len1 = aNode.length;
for (var n = 0; n != len1; n++) {
piece[n] = [];
len2 = aNode[n].firstChild.childNodes.length;
for (var j = 0; j != len2; j++) {
piece[n][j] = aNode[n].firstChild.childNodes[j].attributes.piece;
}
}
trace(piece[1][1]); // traces imgB2.jpg
}
/* produces this array
Variable _level0.piece = [object #2, class 'Array'] [
0:[object #3, class 'Array'] [
0:"imgA1.jpg",
1:"imgA2.jpg"
],
1:[object #4, class 'Array'] [
0:"imgB1.jpg",
1:"imgB2.jpg"
]
]
*/
-
Senior Member
Thanks, I had some errors in my XML, as well as elsewhere in my code
/Flip
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
|