Re: [Flashcoders] xml parsing problem

2006-10-27 Thread Julien V.

Bill,
Take a look at kirupa's XML guide here:
http://www.kirupa.com/web/xml/XMLwayAround2.htm

I also came across the same problem some time ago. I decided not to play 
with siblings because our xml schema (especially the order of the 
sibling nodes) couldn't be predictable. So I went to a custom parsing 
process based on the nodeName of each child node of my sibling nodes.


Something like:

var subItemObject:Object = {};
var subItemChildNodes:Array = subItemNode.childNodes;
for (var i:Number = 0; i  subItemChildNodes.length; i++) {
  var attributeNode:XMLNode = subItemChildNodes[i];
  var attrName:String = attributeNode.nodeName;
  var attrValue:String = attributeNode.firstChild.nodeValue;
  subItemObject[attrName] = attrValue;
}

Hope it helps,

Julien Vignali

Bill Pelon a écrit :
I'm having trouble grabbing the right value from a node any help would 
be awesome.. I can't figure out where to increment as I'm going through 
my loop for the sub items.


node structure below 
NetworkLeftnav


mainItem name=main item name goes here url=url goes here 
window=_self open=true



subItem

textsub item name goes here/text

urlsub item URL goes here/url

window_self/window

/subItem


subItem

textsub item name goes here # 2/text

urlsub item URL # 2/url

window_self/window

/subItem


/mainItem


mainItem name=main item 2 url=main item url #2 window=_self 
open=false



/mainItem


/NetworkLeftnav

AS below 

onClipEvent(load){
function ExpandData(turbo){
var turboItem = turbo.firstChild.childNodes;
var subItem = turbo.firstChild.firstChild.childNodes;
trace(number of main section nodes + 
turbo.firstChild.childNodes.length); // main section count

for (var i = 0; i  turboItem.length; i++){
 var turbo = turboItem[i];
// running through main nodes
 mainNavName = turbo.attributes.name;
 mainNavUrl = turbo.attributes.url;
 mainNavWindow = turbo.attributes.window;
 mainNavOn = turbo.attributes.open; // set to true or false

trace(mainNaveName =  + mainNavName);
trace(mainNaveURL =  + mainNavURL);
trace(mainNaveWindow =  + mainNavWindow);
trace(mainNaveOn =  + mainNavOn);

 if( turbo.childNodes.length =1){
  trace(this node has subcontent);
  trace(number of subcontent nodes = + turbo.childNodes.length);

   turboChild = turbo.firstChild.firstChild;
   trace( );
   trace(total times to loop =  + turbo.childNodes.length);


  for (var n = 0; n  turbo.childNodes.length; n++){
   trace(Subcounter incremental value =  + n);

/ THESE NEED TO BE INCRIMENTED

   trace(turboChild.firstChild.nodeValue); // returns sub item name
   trace(turboChild.nextSibling.firstChild.nodeValue); // returns sub 
item URL
   trace(turboChild.nextSibling.nextSibling.firstChild.nodeValue); // 
returns sub itemWindow

  }
}
trace( );
 }


}

var turbo = new XML();
turbo.ignoreWhite = true;
turbo.onLoad = function(success){
if (success) ExpandData(this);
else trace(Error loading XML file);
}
turbo.load(netnav.xml);  // what my xml is called that is posted above
stop();
}
___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


RE: [Flashcoders] xml parsing problem

2006-10-27 Thread Jack Doyle
You might want to try using my XMLParser class. It translates the XML into
ActionScript-friendly arrays/objects. 

http://www.greensock.com/ActionScript/XMLParser.zip

Jack Doyle

-Original Message-
Date: Thu, 26 Oct 2006 22:13:50 -0400
From: Bill Pelon [EMAIL PROTECTED]
Subject: [Flashcoders] xml parsing problem

I'm having trouble grabbing the right value from a node any help would be
awesome.. I can't figure out where to increment as I'm going through my loop
for the sub items.

node structure below 
NetworkLeftnav

mainItem name=main item name goes here url=url goes here window=_self

open=true

subItem
textsub item name goes here/text
urlsub item URL goes here/url
window_self/window
/subItem

subItem
textsub item name goes here # 2/text
urlsub item URL # 2/url
window_self/window
/subItem

/mainItem

mainItem name=main item 2 url=main item url #2 window=_self 
open=false
/mainItem

/NetworkLeftnav

AS below 

onClipEvent(load){
function ExpandData(turbo){
var turboItem = turbo.firstChild.childNodes; var subItem =
turbo.firstChild.firstChild.childNodes;
trace(number of main section nodes + turbo.firstChild.childNodes.length);
// main section count
for (var i = 0; i  turboItem.length; i++){
  var turbo = turboItem[i];
// running through main nodes
  mainNavName = turbo.attributes.name;
  mainNavUrl = turbo.attributes.url;
  mainNavWindow = turbo.attributes.window;
  mainNavOn = turbo.attributes.open; // set to true or false

trace(mainNaveName =  + mainNavName);
trace(mainNaveURL =  + mainNavURL);
trace(mainNaveWindow =  + mainNavWindow); trace(mainNaveOn =  +
mainNavOn);

  if( turbo.childNodes.length =1){
   trace(this node has subcontent);
   trace(number of subcontent nodes = + turbo.childNodes.length);

turboChild = turbo.firstChild.firstChild;
trace( );
trace(total times to loop =  + turbo.childNodes.length);


   for (var n = 0; n  turbo.childNodes.length; n++){
trace(Subcounter incremental value =  + n);

/ THESE NEED TO BE INCRIMENTED

trace(turboChild.firstChild.nodeValue); // returns sub item name
trace(turboChild.nextSibling.firstChild.nodeValue); // returns sub item
URL
trace(turboChild.nextSibling.nextSibling.firstChild.nodeValue); //
returns sub itemWindow
   }
 }
 trace( );
  }

}

var turbo = new XML();
turbo.ignoreWhite = true;
turbo.onLoad = function(success){
 if (success) ExpandData(this);
 else trace(Error loading XML file);
}
turbo.load(netnav.xml);  // what my xml is called that is posted above
stop(); } 




___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


RE: [Flashcoders] xml parsing problem

2006-10-27 Thread Steven Sacks | BLITZ
Or you could use XML2AS.

// XML2AS - DO NOT AUTO FORMAT!
_global.XML2AS = function(n, r) {
var a, d, k;
if (r[k=n.nodeName] == null) r = ((a=r[k]=[{}]))[d=0];
else r = (a=r[k])[d=r[k].push({})-1];
if (n.hasChildNodes()) {
if ((k=n.firstChild.nodeType) == 1) {
r.attributes = n.attributes;
for (var i in k=n.childNodes) XML2AS(k[i], r);
} else if (k == 3) {
a[d] = new String(n.firstChild.nodeValue);
a[d].attributes = n.attributes;
}
}else r.attributes = n.attributes;
}
___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


Re: [Flashcoders] xml parsing problem

2006-10-27 Thread Jim Kremens

Steven,

It would be cool if you made a version of that that was mtasc compatible...

Jim Kremens


On 10/27/06, Steven Sacks | BLITZ [EMAIL PROTECTED] wrote:

Or you could use XML2AS.

// XML2AS - DO NOT AUTO FORMAT!
_global.XML2AS = function(n, r) {
   var a, d, k;
   if (r[k=n.nodeName] == null) r = ((a=r[k]=[{}]))[d=0];
   else r = (a=r[k])[d=r[k].push({})-1];
   if (n.hasChildNodes()) {
   if ((k=n.firstChild.nodeType) == 1) {
   r.attributes = n.attributes;
   for (var i in k=n.childNodes) XML2AS(k[i], r);
   } else if (k == 3) {
   a[d] = new String(n.firstChild.nodeValue);
   a[d].attributes = n.attributes;
   }
   }else r.attributes = n.attributes;
}
___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com




--
Jim Kremens
___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


RE: [Flashcoders] xml parsing problem

2006-10-27 Thread Merrill, Jason
Can you provide some usage instructions (i.e. what the arguments n and r
are for)?

Jason Merrill
Bank of America 
Learning  Organization Effectiveness - Technology Solutions 
 
 
 
 
 

-Original Message-
From: [EMAIL PROTECTED] [mailto:flashcoders-
[EMAIL PROTECTED] On Behalf Of Steven Sacks | BLITZ
Sent: Friday, October 27, 2006 4:47 PM
To: Flashcoders mailing list
Subject: RE: [Flashcoders] xml parsing problem

Or you could use XML2AS.

// XML2AS - DO NOT AUTO FORMAT!
_global.XML2AS = function(n, r) {
var a, d, k;
if (r[k=n.nodeName] == null) r = ((a=r[k]=[{}]))[d=0];
else r = (a=r[k])[d=r[k].push({})-1];
if (n.hasChildNodes()) {
if ((k=n.firstChild.nodeType) == 1) {
r.attributes = n.attributes;
for (var i in k=n.childNodes) XML2AS(k[i], r);
} else if (k == 3) {
a[d] = new String(n.firstChild.nodeValue);
a[d].attributes = n.attributes;
}
}else r.attributes = n.attributes;
}
___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com
___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


[Flashcoders] xml parsing problem

2006-10-26 Thread Bill Pelon
I'm having trouble grabbing the right value from a node any help would be 
awesome.. I can't figure out where to increment as I'm going through my loop 
for the sub items.


node structure below 
NetworkLeftnav


mainItem name=main item name goes here url=url goes here window=_self 
open=true



subItem

textsub item name goes here/text

urlsub item URL goes here/url

window_self/window

/subItem


subItem

textsub item name goes here # 2/text

urlsub item URL # 2/url

window_self/window

/subItem


/mainItem


mainItem name=main item 2 url=main item url #2 window=_self 
open=false



/mainItem


/NetworkLeftnav

AS below 

onClipEvent(load){
function ExpandData(turbo){
var turboItem = turbo.firstChild.childNodes;
var subItem = turbo.firstChild.firstChild.childNodes;
trace(number of main section nodes + turbo.firstChild.childNodes.length); 
// main section count

for (var i = 0; i  turboItem.length; i++){
 var turbo = turboItem[i];
// running through main nodes
 mainNavName = turbo.attributes.name;
 mainNavUrl = turbo.attributes.url;
 mainNavWindow = turbo.attributes.window;
 mainNavOn = turbo.attributes.open; // set to true or false

trace(mainNaveName =  + mainNavName);
trace(mainNaveURL =  + mainNavURL);
trace(mainNaveWindow =  + mainNavWindow);
trace(mainNaveOn =  + mainNavOn);

 if( turbo.childNodes.length =1){
  trace(this node has subcontent);
  trace(number of subcontent nodes = + turbo.childNodes.length);

   turboChild = turbo.firstChild.firstChild;
   trace( );
   trace(total times to loop =  + turbo.childNodes.length);


  for (var n = 0; n  turbo.childNodes.length; n++){
   trace(Subcounter incremental value =  + n);

/ THESE NEED TO BE INCRIMENTED

   trace(turboChild.firstChild.nodeValue); // returns sub item name
   trace(turboChild.nextSibling.firstChild.nodeValue); // returns sub item 
URL
   trace(turboChild.nextSibling.nextSibling.firstChild.nodeValue); // 
returns sub itemWindow

  }
}
trace( );
 }


}

var turbo = new XML();
turbo.ignoreWhite = true;
turbo.onLoad = function(success){
if (success) ExpandData(this);
else trace(Error loading XML file);
}
turbo.load(netnav.xml);  // what my xml is called that is posted above
stop();
} 


___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com