xml analizar la matriz

  • taufiq
  • Newbie
  • Newbie
  • No Avatar
  • Registrado: Nov 24, 2008
  • Mensajes: 7
  • Status: Offline

Nota Noviembre 24th, 2008, 4:24 am

Hola, chicos, gracias por tomarse el tiempo para leer este hilo,
soy novato en la forma y el estrés recibiendo ahora, así que espero que alguien me puede ayudar
He XML http://localhost/subcat/index.php/movie/genre , y este es el código
Código: [ Select ]
<?xml version="1.0" encoding="UTF-8"?>
<data>
<genre id="1">
<id>1</id>
<root>0</root>
<name>Action</name>
<description>Action</description>
</genre>

<genre id="6">

<id>6</id>
<root>0</root>
<name>Thriller</name>
<description>Thriller</description>
</genre>

<genre id="7">
<id>7</id>

<root>0</root>
<name>Comedy</name>
<description>Comedy</description>
</genre>

<genre id="8">
<id>8</id>
<root>0</root>
<name>Romantic Comedy</name>

<description>Romantic Comedy</description>
</genre>

<genre id="10">
<id>10</id>
<root>0</root>
<name>Classics</name>
<description>Classics</description>
</genre>

<genre id="11">
<id>11</id>
<root>0</root>
<name>Cult</name>
<description>Cult</description>
</genre>

<genre id="12">

<id>12</id>
<root>0</root>
<name>Documentary</name>
<description>Documentary</description>
</genre>

<genre id="13">
<id>13</id>

<root>0</root>
<name>Indie / Foreign</name>
<description>Indie / Foreign</description>
</genre>

<genre id="15">
<id>15</id>
<root>0</root>
<name>Children</name>

<description>Children</description>
</genre>

<genre id="16">
<id>16</id>
<root>0</root>
<name>Musicals</name>
<description>Musicals</description>
</genre>

<genre id="18">
<id>18</id>
<root>0</root>
<name>TV Shows</name>
<description>TV Shows</description>
</genre>

<genre id="19">

<id>19</id>
<root>0</root>
<name>War</name>
<description>War</description>
</genre>

<genre id="23">
<id>23</id>

<root>0</root>
<name>Drama</name>
<description>Drama</description>
</genre>

<genre id="31">
<id>31</id>
<root>0</root>
<name>Music & Concert</name>

<description>Music & Concert</description>
</genre>

<genre id="43">
<id>43</id>
<root>13</root>
<name>special collection</name>
<description></description>
</genre>

<genre id="44">
<id>44</id>
<root>13</root>
<name>criterion collection</name>
<description></description>
</genre>

</data>
</xml>
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <data>
  3. <genre id="1">
  4. <id>1</id>
  5. <root>0</root>
  6. <name>Action</name>
  7. <description>Action</description>
  8. </genre>
  9. <genre id="6">
  10. <id>6</id>
  11. <root>0</root>
  12. <name>Thriller</name>
  13. <description>Thriller</description>
  14. </genre>
  15. <genre id="7">
  16. <id>7</id>
  17. <root>0</root>
  18. <name>Comedy</name>
  19. <description>Comedy</description>
  20. </genre>
  21. <genre id="8">
  22. <id>8</id>
  23. <root>0</root>
  24. <name>Romantic Comedy</name>
  25. <description>Romantic Comedy</description>
  26. </genre>
  27. <genre id="10">
  28. <id>10</id>
  29. <root>0</root>
  30. <name>Classics</name>
  31. <description>Classics</description>
  32. </genre>
  33. <genre id="11">
  34. <id>11</id>
  35. <root>0</root>
  36. <name>Cult</name>
  37. <description>Cult</description>
  38. </genre>
  39. <genre id="12">
  40. <id>12</id>
  41. <root>0</root>
  42. <name>Documentary</name>
  43. <description>Documentary</description>
  44. </genre>
  45. <genre id="13">
  46. <id>13</id>
  47. <root>0</root>
  48. <name>Indie / Foreign</name>
  49. <description>Indie / Foreign</description>
  50. </genre>
  51. <genre id="15">
  52. <id>15</id>
  53. <root>0</root>
  54. <name>Children</name>
  55. <description>Children</description>
  56. </genre>
  57. <genre id="16">
  58. <id>16</id>
  59. <root>0</root>
  60. <name>Musicals</name>
  61. <description>Musicals</description>
  62. </genre>
  63. <genre id="18">
  64. <id>18</id>
  65. <root>0</root>
  66. <name>TV Shows</name>
  67. <description>TV Shows</description>
  68. </genre>
  69. <genre id="19">
  70. <id>19</id>
  71. <root>0</root>
  72. <name>War</name>
  73. <description>War</description>
  74. </genre>
  75. <genre id="23">
  76. <id>23</id>
  77. <root>0</root>
  78. <name>Drama</name>
  79. <description>Drama</description>
  80. </genre>
  81. <genre id="31">
  82. <id>31</id>
  83. <root>0</root>
  84. <name>Music & Concert</name>
  85. <description>Music & Concert</description>
  86. </genre>
  87. <genre id="43">
  88. <id>43</id>
  89. <root>13</root>
  90. <name>special collection</name>
  91. <description></description>
  92. </genre>
  93. <genre id="44">
  94. <id>44</id>
  95. <root>13</root>
  96. <name>criterion collection</name>
  97. <description></description>
  98. </genre>
  99. </data>
  100. </xml>


y ahora, quiero analizar el XML y obtener el ID del nudo de este XML
así Heres el código:

Código: [ Select ]
/*global variabel declare*/
var label:TextField;
var duplicate_genre:MovieClip;
/*end declare*/
/*Opening connection with xml*/
myXML = new XML();
var id:Array;
var path_id:Array;
myXML.ignoreWhite = true;
myXML.load("http://localhost/subcat/index.php/movie/genre");
myXML.ref = this;
myXML.onLoad = function(succes) {
if (succes) {
var root = this.firstChild;
var nodes = root.childNodes;
for (var i = 0; i<nodes.length; i++) {
subnodes = nodes[i].childNodes;
duplicate_genre= _root.genre.createEmptyMovieClip(["container"+i], _root.genre.getNextHighestDepth());/*make container for dynamic txt genre*/
this["label"+i]=duplicate_genre.createTextField(["labelor"+i], 1, -422, (i*28.5)+(-200), 143.8, 22.6);/*declare position text for genre*/
/*conditional if text <20*/
if (i<20) {
this["label"+i].text = subnodes[2].firstChild.toString();/*write genre xml to dynamic text*/
path_id=_root.genre["id"+i]= this["container"+i]=subnodes[0].firstChild.toString();/*declare id genre xml*/
trace(duplicate_genre+path_id);
/*opening otherXML */
otherXML = new XML()
otherXML.ignoreWhite = true
duplicate_genre.onRelease = function() {
var string="http://localhost/subcat/index.php/movie/lists/1/"+_root.genre.path_id;/*declare url for movie list*/
trace(string);
otherXML.load(string);/*function for load url movie*/
otherXML.onLoad = function(succes) {
if (succes) {
var totalpage = this.childNodes[1].firstChild.toString();
totalpage_txt.text = "("+totalpage+" Movies)";/*function for display total page*/
var root = this.firstChild;
nodes = root.childNodes;
for (var i = 0; i<nodes.length; i++) {
subnodes = nodes[i].childNodes;
_root.genre["cover_title"+i].text = subnodes[1].firstChild.toString();/*function for display movie name*/
_root.genre["genre_name"].text = subnodes[3].firstChild.toString();/*function for display genre name*/
}
} else {
trace("Error loading otherXML");
}
};/*end other xml load function*/
};/*end conditional for on release*/
} else {
trace("erorr loading xml document");
}/*end if text < 20*/
}/*end for Myxml*/
} else {
trace("Error loading XML document");
}
};
/*end connection for myXML*/
  1. /*global variabel declare*/
  2. var label:TextField;
  3. var duplicate_genre:MovieClip;
  4. /*end declare*/
  5. /*Opening connection with xml*/
  6. myXML = new XML();
  7. var id:Array;
  8. var path_id:Array;
  9. myXML.ignoreWhite = true;
  10. myXML.load("http://localhost/subcat/index.php/movie/genre");
  11. myXML.ref = this;
  12. myXML.onLoad = function(succes) {
  13. if (succes) {
  14. var root = this.firstChild;
  15. var nodes = root.childNodes;
  16. for (var i = 0; i<nodes.length; i++) {
  17. subnodes = nodes[i].childNodes;
  18. duplicate_genre= _root.genre.createEmptyMovieClip(["container"+i], _root.genre.getNextHighestDepth());/*make container for dynamic txt genre*/
  19. this["label"+i]=duplicate_genre.createTextField(["labelor"+i], 1, -422, (i*28.5)+(-200), 143.8, 22.6);/*declare position text for genre*/
  20. /*conditional if text <20*/
  21. if (i<20) {
  22. this["label"+i].text = subnodes[2].firstChild.toString();/*write genre xml to dynamic text*/
  23. path_id=_root.genre["id"+i]= this["container"+i]=subnodes[0].firstChild.toString();/*declare id genre xml*/
  24. trace(duplicate_genre+path_id);
  25. /*opening otherXML */
  26. otherXML = new XML()
  27. otherXML.ignoreWhite = true
  28. duplicate_genre.onRelease = function() {
  29. var string="http://localhost/subcat/index.php/movie/lists/1/"+_root.genre.path_id;/*declare url for movie list*/
  30. trace(string);
  31. otherXML.load(string);/*function for load url movie*/
  32. otherXML.onLoad = function(succes) {
  33. if (succes) {
  34. var totalpage = this.childNodes[1].firstChild.toString();
  35. totalpage_txt.text = "("+totalpage+" Movies)";/*function for display total page*/
  36. var root = this.firstChild;
  37. nodes = root.childNodes;
  38. for (var i = 0; i<nodes.length; i++) {
  39. subnodes = nodes[i].childNodes;
  40. _root.genre["cover_title"+i].text = subnodes[1].firstChild.toString();/*function for display movie name*/
  41. _root.genre["genre_name"].text = subnodes[3].firstChild.toString();/*function for display genre name*/
  42. }
  43. } else {
  44. trace("Error loading otherXML");
  45. }
  46. };/*end other xml load function*/
  47. };/*end conditional for on release*/
  48. } else {
  49. trace("erorr loading xml document");
  50. }/*end if text < 20*/
  51. }/*end for Myxml*/
  52. } else {
  53. trace("Error loading XML document");
  54. }
  55. };
  56. /*end connection for myXML*/


el problema comienza aquí, cuando quiero tomar ID del nudo en XML y de análisis que en http://localhost/subcat/index.php/movie/lists/1/ "+ _root.genre. path_id,
Im siempre obtener id desde la última xml que es "44", y no puede ser adecuada con el envase que te hice clic,
u puede ver los problemas??
Lo siento mi Inglés pobres
Alguien tiene consejos???
de lo contrario, deben tener idNode de la película / género al hacer clic, y luego colocar a la película / lists / i, que i es ID de la película / género
gracias...
please help me....
  • Anonymous
  • Bot
  • No Avatar
  • Registrado: 25 Feb 2008
  • Mensajes: ?
  • Loc: Ozzuland
  • Status: Online

Nota Noviembre 24th, 2008, 4:24 am

  • graphixboy
  • Control + Z
  • Mastermind
  • Avatar de Usuario
  • Registrado: Jul 11, 2005
  • Mensajes: 1828
  • Loc: In the Great White North
  • Status: Offline

Nota Noviembre 24th, 2008, 9:13 am

Alguien no está seguro exactamente lo que piden su THERES pero una muy buena xml / as en el tutorial Kirupa (versión AS3) y (AS2, versión) . Es posible que desee leer y ver que si se da respuesta a tus preguntas. Lo siento yo no podría ser más ayuda.
If at first you don't succeed F1... If that doesn't work try Google!
//// Designer, Developer & Teacher - Interactive, Motion and 3D \\\\
Portfolio at WhenImNotSleeping.com
  • taufiq
  • Newbie
  • Newbie
  • No Avatar
  • Registrado: Nov 24, 2008
  • Mensajes: 7
  • Status: Offline

Nota Noviembre 24th, 2008, 11:53 am

hi graphicxx niño, gracias fot su representante.
Trataré de contarles más detalles,

en primer lugar, XML carga i y analizar con algún elemento, el campo de texto, por ejemplo,
y como se puede ver en mi XML ( http://localhost/subcat/index.php/movie/genre ) He <id> nodo, y quiero que, cuando se hace clic en uno de clip de película, será analizar <id> nodo en la nueva URL que se
"http://localhost/subcat/index. php / película / lists / "+ id, que es variable de ID de <id> nodo de http://localhost/subcat/index.php/movie/genre,before

Hice el código para esta lógica, como que,
Código: [ Select ]
duplicate_genre.onRelease = function() {
var string="http://localhost/subcat/index.php/movie/list//"+_root.genre.path_id;/*declare url for movie list*/
trace(string);
  1. duplicate_genre.onRelease = function() {
  2. var string="http://localhost/subcat/index.php/movie/list//"+_root.genre.path_id;/*declare url for movie list*/
  3. trace(string);


, pero, este código sólo trazas para la identificación del pasado (44), y puede ser adecuado con el ID de la película lo que hizo clic,

ca u ver los problemas??
  • graphixboy
  • Control + Z
  • Mastermind
  • Avatar de Usuario
  • Registrado: Jul 11, 2005
  • Mensajes: 1828
  • Loc: In the Great White North
  • Status: Offline

Nota Noviembre 24th, 2008, 12:20 pm

ahh ok yo veo lo que tu pregunta. El problema es que el uso de un bucle con una variable dentro de la misma. Cada iteración (bucle) la variable se sobrescribe con el valor más recientes. Por lo tanto, cuando se intenta obtener el valor de la variable después del ciclo corrió a obtener el valor de último acceso.

la forma de evitar esto es para almacenar el valor como una variable independiente en cada iteración del bucle. Probablemente, la solución más fácil es atribuir el valor a tu botón...
Código: [ Select ]
duplicate_genre.targ = path_id; // you declare the path_id previously, now your storing it in the clip.
duplicate_genre.onRelease = function() {
trace(this.targ); // this being the clip and targ is the name we gave it
}
  1. duplicate_genre.targ = path_id; // you declare the path_id previously, now your storing it in the clip.
  2. duplicate_genre.onRelease = function() {
  3. trace(this.targ); // this being the clip and targ is the name we gave it
  4. }
If at first you don't succeed F1... If that doesn't work try Google!
//// Designer, Developer & Teacher - Interactive, Motion and 3D \\\\
Portfolio at WhenImNotSleeping.com
  • taufiq
  • Newbie
  • Newbie
  • No Avatar
  • Registrado: Nov 24, 2008
  • Mensajes: 7
  • Status: Offline

Nota Noviembre 24th, 2008, 12:53 pm

muchas gracias, u finnaly ver los problemas: _)

Sí, esto es lo que quiero decir,
siempre que la reproducción en bucle, para que podamos almacenar en el botón de identificación,
pero lo siento, donde tenemos var: Targ?
thats imagen en movimiento
gracias
  • taufiq
  • Newbie
  • Newbie
  • No Avatar
  • Registrado: Nov 24, 2008
  • Mensajes: 7
  • Status: Offline

Nota Noviembre 24th, 2008, 1:53 pm

¿qué? que fija,
gracias graphixbox por qué no im thinked como un simple que,

tanto las gracias,,,
gracias :D
  • graphixboy
  • Control + Z
  • Mastermind
  • Avatar de Usuario
  • Registrado: Jul 11, 2005
  • Mensajes: 1828
  • Loc: In the Great White North
  • Status: Offline

Nota Noviembre 25th, 2008, 6:07 pm

usted la bienvenida. Buena suerte.
If at first you don't succeed F1... If that doesn't work try Google!
//// Designer, Developer & Teacher - Interactive, Motion and 3D \\\\
Portfolio at WhenImNotSleeping.com

Publicar Información

  • Total de mensajes en este tema: 7 mensajes
  • Usuarios navegando por este Foro: No hay usuarios registrados visitando el Foro y 51 invitados
  • No puede abrir nuevos temas en este Foro
  • No puede responder a temas en este Foro
  • No puede editar sus mensajes en este Foro
  • No puede borrar sus mensajes en este Foro
  • No puede enviar adjuntos en este Foro
 
 

© 2011 Unmelted, LLC. Ozzu® es una marca registrada de Unmelted, LLC