[flexcoders] Re: Building flat data object based on XML file with complicated structure

2006-06-21 Thread wayneposner
H

Let's try again :)  


  item id=0006 name=ASSY, SPLIT CLUTCH COVER
item id=0001 name=SPLIT CLUTCH COVER
  item id=0001 name=CLUTCH COVER MACH.
item id=0001 name=CLUTCH COVER WELDMENT
  item id=0001 name=HR PLATE
item id=0010 name=PLATE(A572-50)/
  /item
  item id=0002 name=TUBING
item id=0001 name=15X13-1/2 TUBING C1026/
  /item
  item id=0003 name=PLATE
item id=0010 name=PLATE(A572-50)/
  /item
  item id=0004 name=END TUBE
item id=0001 name=PLATE(A572-50)/
  /item
  item id=0005 name=END PLATE
item id=0001 name=PLATE(A572-50)/
  /item
/item
  /item
/item

I removed some of the extra attributes to get it to format 
correctly.  Hopefully this works. 


--- In flexcoders@yahoogroups.com, Tracy Spratt [EMAIL PROTECTED] 
wrote:

 Is there anyway to post that xml so it stays formatted?  I really 
do not
 like that part of the new yahoo groups.
 
 Tracy
 
  
 
 
 
 From: flexcoders@yahoogroups.com 
[mailto:[EMAIL PROTECTED] On
 Behalf Of wayneposner
 Sent: Wednesday, June 21, 2006 2:44 PM
 To: flexcoders@yahoogroups.com
 Subject: [flexcoders] Building flat data object based on XML 
file with
 complicated structure
 
  
 
 Howdy all!!
 
 Take the following blurb of XML:
 
 item id=0006 qty=2.000 uom=EA matnr=347565 
 bismt=DBT347565 name=ASSY, SPLIT CLUTCH COVER hasBom=X 
 path=pdf/347565.pdf image=pdf/thumbnails/347565.jpg
 item id=0001 qty=1.000 uom=EA matnr=347564 
 bismt=DBT347564 name=SPLIT CLUTCH COVER hasBom=X 
 path=pdf/347564.pdf image=pdf/thumbnails/347564.jpg
 item id=0001 qty=1.000 uom=EA matnr=313551 
 bismt=DBT313551 name=CLUTCH COVER MACH. hasBom=X 
 path=pdf/313551.pdf image=pdf/thumbnails/313551.jpg
 item id=0001 qty=1.000 uom=EA matnr=313552 
 bismt=DBT313552 name=CLUTCH COVER WELDMENT hasBom=X 
 path=pdf/313552.pdf image=pdf/thumbnails/313552.jpg
 item id=0001 qty=1.000 uom=EA matnr=169902 
 bismt=J-548F613MK002 name=HR PLATE hasBom=X 
 path=pdf/169902.pdf image=pdf/thumbnails/169902.jpg
 item id=0010 qty=2.000 uom=FT2 matnr=131877 
 bismt= 008 302 72 61 name=PLATE(A572-50)1.00quot; 
 hasBom=/
 /item
 item id=0002 qty=1.000 uom=EA matnr=313554 
 bismt=DBT313554 name=TUBING hasBom=X path=pdf/313554.pdf 
 image=pdf/thumbnails/313554.jpg
 item id=0001 qty=0.660 uom=IN matnr=169626 
 bismt=J-294-07-026 name=15X13-1/2 TUBING C1026 hasBom=/
 /item
 item id=0003 qty=1.000 uom=EA matnr=169903 
 bismt=J-548F613MK003 name=PLATE hasBom=X 
path=pdf/169903.pdf 
 image=pdf/thumbnails/169903.jpg
 item id=0010 qty=1.200 uom=FT2 matnr=131872 
 bismt= 008 302 72 55 name=PLATE(A572-50).50quot; 
hasBom=/
 /item
 item id=0004 qty=1.000 uom=EA matnr=313556 
 bismt=DBT313556 name=END TUBE hasBom=X path=pdf/313556.pdf 
 image=pdf/thumbnails/313556.jpg
 item id=0001 qty=0.800 uom=FT2 matnr=131883 
 bismt= 008 302 72 67 name=PLATE(A572-50)1.50quot; 
 hasBom=/
 /item
 item id=0005 qty=1.000 uom=EA matnr=313557 
 bismt=DBT313557 name=END PLATE hasBom=X 
path=pdf/313557.pdf 
 image=pdf/thumbnails/313557.jpg
 item id=0001 qty=0.600 uom=FT2 matnr=131872 
 bismt= 008 302 72 55 name=PLATE(A572-50).50quot; 
hasBom=/
 /item
 /item
 /item
 /item
 
 I've been trying to build an array of objects of it and flatten it 
 down so that each item node would simply be an entry in the array. 
 If I use a recursive function, I only get the deepest node 
 returned. If I use the for each (var prop:XML in myXML.item) 
loop 
 I only get the children of the root and not the grandchildren. How 
 do I get EVERY node???
 
 Thanks!
 
 Wayne








 Yahoo! Groups Sponsor ~-- 
Great things are happening at Yahoo! Groups.  See the new email design.
http://us.click.yahoo.com/TISQkA/hOaOAA/yQLSAA/nhFolB/TM
~- 

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

* To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

* To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

* Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
 





[flexcoders] Re: Building flat data object based on XML file with complicated structure

2006-06-21 Thread wayneposner
Hi Tracy..

Thanks so much, your code got me on the right track.  Some slight 
modifications gave me exactly what I needed!  As for the XML, I must 
not have copied/pasted enough info from the full xml file.

Thanks again for your help!  You rock!!!

Wayne

-- In flexcoders@yahoogroups.com, Tracy Spratt [EMAIL PROTECTED] wrote:

 BTW, you xml is not valid, the closing tag is missing on the End 
Plate
 node.  I fixed it in my example
 
 Tracy
 
  
 
 
 
 From: flexcoders@yahoogroups.com 
[mailto:[EMAIL PROTECTED] On
 Behalf Of Tracy Spratt
 Sent: Wednesday, June 21, 2006 9:06 PM
 To: flexcoders@yahoogroups.com
 Subject: RE: [flexcoders] Re: Building flat data object based on 
XML
 file with complicated structure
 
  
 
 Try this sample app.  If I have understood you correctly, it 
should do
 what you want.  The key is the descendants property.
 
 Tracy
 
 ?xml version=1.0 encoding=utf-8?
 
 mx:Application xmlns:mx=http://www.adobe.com/2006/mxml;
 layout=absolute
 
 creationComplete=buildArray()
 
 mx:Script![CDATA[ 
 
  
 
   private function buildArray() :void 
 
   {
 
 var aNodes:Array = new Array();
 
 var xmlToProcess:XML = item id=0006 name=ASSY, SPLIT CLUTCH
 COVER
 
 item id=0001 name=SPLIT 
CLUTCH
 COVER
 
 item id=0001
 name=CLUTCH COVER MACH.
 
 item
 id=0001 name=CLUTCH COVER WELDMENT
 
  
 item id=0001 name=HR PLATE
 
  
 item id=0010 name=PLATE(A572-50)/
 
  
 /item
 
  
 item id=0002 name=TUBING
 
  
 item id=0001 name=15X13-1/2 TUBING C1026/
 
  
 /item
 
  
 item id=0003 name=PLATE
 
  
 item id=0010 name=PLATE(A572-50)/
 
  
 /item
 
  
 item id=0004 name=END TUBE
 
  
 item id=0001 name=PLATE(A572-50)/
 
  
 /item
 
  
 item id=0005 name=END PLATE
 
  
 item id=0001 name=PLATE(A572-50)/
 
  
 /item
 
 /item
 
 /item
 
 /item
 
   /item
 
   
 
   var xlConverted:XMLList = xmlToProcess.descendants(*);
 
   trace (xlConverted.length());
 
   var xmlNode:XML;
 
   for (var i:int = 0; i xlConverted.length(); i++) {
 
 xmlNode = xlConverted[i];
 
 trace ([EMAIL PROTECTED]);
 
 aNodes.push(xmlNode);
 
   }
 
   trace(aNodes.length);
 
  
 
   } 
 
 ]]/mx:Script
 
 /mx:Application
 
  
 
 
 
 From: flexcoders@yahoogroups.com 
[mailto:[EMAIL PROTECTED] On
 Behalf Of wayneposner
 Sent: Wednesday, June 21, 2006 7:38 PM
 To: flexcoders@yahoogroups.com
 Subject: [flexcoders] Re: Building flat data object based on XML 
file
 with complicated structure
 
  
 
 H
 
 Let's try again :) 
 
 item id=0006 name=ASSY, SPLIT CLUTCH COVER
 item id=0001 name=SPLIT CLUTCH COVER
 item id=0001 name=CLUTCH COVER MACH.
 item id=0001 name=CLUTCH COVER WELDMENT
 item id=0001 name=HR PLATE
 item id=0010 name=PLATE(A572-50)/
 /item
 item id=0002 name=TUBING
 item id=0001 name=15X13-1/2 TUBING C1026/
 /item
 item id=0003 name=PLATE
 item id=0010 name=PLATE(A572-50)/
 /item
 item id=0004 name=END TUBE
 item id=0001 name=PLATE(A572-50)/
 /item
 item id=0005 name=END PLATE
 item id=0001 name=PLATE(A572-50)/
 /item
 /item
 /item
 /item
 
 I removed some of the extra attributes to get it to format 
 correctly. Hopefully this works. 
 
 --- In flexcoders@yahoogroups.com mailto:flexcoders%
40yahoogroups.com
 , Tracy Spratt tspratt@ 
 wrote:
 
  Is there anyway to post that xml so it stays formatted? I really 
 do not
  like that part of the new yahoo groups.
  
  Tracy
  
  
  
  
  
  From: flexcoders@yahoogroups.com mailto:flexcoders%
40yahoogroups.com
 
 [mailto:flexcoders@yahoogroups.com mailto:flexcoders%
40yahoogroups.com
 ] On
  Behalf Of wayneposner
  Sent: Wednesday, June 21, 2006 2:44 PM
  To: flexcoders@yahoogroups.com mailto:flexcoders%
40yahoogroups.com 
  Subject: [flexcoders] Building flat data object based on XML 
 file with
  complicated structure
  
  
  
  Howdy all!!
  
  Take the following blurb of XML:
  
  item id=0006 qty=2.000 uom=EA matnr=347565 
  bismt=DBT347565 name=ASSY, SPLIT CLUTCH COVER hasBom=X 
  path=pdf/347565.pdf image=pdf/thumbnails/347565.jpg
  item id=0001 qty=1.000 uom=EA matnr=347564 
  bismt=DBT347564 name=SPLIT CLUTCH COVER hasBom=X 
  path=pdf/347564.pdf image=pdf/thumbnails/347564.jpg
  item id=0001 qty=1.000 uom=EA matnr=313551 
  bismt=DBT313551 name=CLUTCH COVER MACH. hasBom=X 
  path=pdf/313551.pdf image=pdf/thumbnails/313551.jpg
  item id=0001 qty=1.000 uom=EA matnr=313552 
  bismt=DBT313552 name=CLUTCH COVER WELDMENT hasBom=X 
  path=pdf/313552.pdf image=pdf/thumbnails/313552.jpg
  item id=0001 qty=1.000 uom=EA matnr=169902 
  bismt=J-548F613MK002 name=HR PLATE hasBom=X 
  path=pdf/169902