A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: childNodes returning Xtra children???

  1. #1
    Senior Member
    Join Date
    Apr 2001
    Location
    UK
    Posts
    493

    childNodes returning Xtra children???

    Hi,

    Confessed XML donkey though i am, has any body else had problems with childNodes giving more nodes than is there?

    This sounds mental i know, but i have a node that has 10 child nodes... i know this as its from a SQL statement that selects Top 10....and i can see that it has..... but if i check the returned XML Doc
    Code:
    	var dataNode:XMLNode=dbData.childNodes[1]
    	trace("dataNode - :"+dataNode.childNodes.length)
    ...it gives me 21!!!

    if i trace out every child i get a node...then nothing...then a node etc..

    the XML doc is thus - copied direct from an output text field..


    Code:
    <dataroot>
    <flsdata>
     <Name>jon1</Name>
     <TotalScore>100</TotalScore>
    </flsdata>
    <flsdata>
     <Name>jon2</Name>
      <TotalScore>99</TotalScore>
    </flsdata>
    <flsdata>
      <Name>jon3</Name>
      <TotalScore>98</TotalScore>
    </flsdata>
    <flsdata>
      <Name>jon4</Name>
      <TotalScore>97</TotalScore>
    </flsdata>
    <flsdata>
      <Name>jon5</Name>
      <TotalScore>96</TotalScore>
    </flsdata>
    <flsdata>
      <Name>jon6</Name>
      <TotalScore>95</TotalScore>
    </flsdata>
    <flsdata>
      <Name>jon7</Name>
      <TotalScore>94</TotalScore>
    </flsdata>
    <flsdata>
      <Name>jon8</Name>
      <TotalScore>93</TotalScore>
    </flsdata>
    <flsdata>
      <Name>jon9</Name>
      <TotalScore>92</TotalScore>
    </flsdata>
    <flsdata>
       <Name>jon10</Name>
       <TotalScore>91</TotalScore>
    </flsdata>
    </dataroot>
    Its got to be something with the file, but i cant see it. If i paste this into a string and create XMl from it it gives me 10!!!!

    I hate XML......so any pointers would be greatly appreciated

    CHeers
    Jon

  2. #2
    up to my .as in code Chris_Seahorn's Avatar
    Join Date
    Dec 2004
    Posts
    4,389
    Saving your xml on my server (as "jayhoo.xml") I get what I should loading it in the usual ways. Your example was for the count so here is the count:

    _root.createTextField("mydata",1,40,40,300,100);

    dbData = new XML();
    dbData.ignoreWhite = true;
    dbData.onLoad = function(success) {
    if (success) {
    var dataNode = dbData.firstChild;
    _root.mydata.text = dataNode.childNodes.length;
    }
    }
    dbData.load("jayhoo.xml");

    stop();

  3. #3
    Senior Member
    Join Date
    Apr 2001
    Location
    UK
    Posts
    493
    thanks for getting back.

    Yeah thats exactly what i get too...unfortunately this XML is being sent via compressed UDP packet. The file looks fine and liek you say if saved gives the correct node count.....

    Unfortunately when checking the actual returned file...its giving me these ghost nodes. I can write a loop to ignore them but a bit annoying and doint like not knowing why its not working!

    Thanks anyway

    Jon

  4. #4
    up to my .as in code Chris_Seahorn's Avatar
    Join Date
    Dec 2004
    Posts
    4,389
    It has to be the compression...when I write it here and run it I have no extra anything. I can run a preview of it running here to show that if need be.

    Chris

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center