Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Loading XML generated by PHP doesn´t work

Community Beginner ,
Oct 06, 2009 Oct 06, 2009

I know what will you say: Search for a tutorial.

Yes, i´ve searched here. Through internet. But i get no answer.


I checked format. This is the xml output:

<?xml version="1.0" ?>
<root>
<nivel nombre='A1'>
<item>
<nombre>audio1</nombre>
<tipo>audio</tipo>
<descargable>si</descargable>
<url>../multimedia/Audios/A1_audio1.MP3</url>
</item>
</nivel>
<nivel nombre='A2'>
<item>
<nombre>leccion1</nombre>
<tipo>texto</tipo>
<descargable>si</descargable><nivel nombre='B1'><item>
<nombre>audio1</nombre>
<tipo>audio</tipo>
<descargable>si</descargable>
<url>../multimedia/Audios/B1_audio1.MP3</url>
</item>
</nivel>
</root>
 

I think the format is perfect. I can read it on my Firefox as a perfect xml.

Now. This is action script code:

            var loader:URLLoader = new URLLoader();
            loader.addEventListener(Event.COMPLETE, cargaXML);
            loader.load(new URLRequest("reproductor_generador_datos.php"));

When loaded i do

trace(e.target.data);

To see the xml, but it´s php. It hasn´t generated it.

I follow every tutorial. This is the way. Is there any other way to make it "EXECUTE" the php code?? it donesn´t seem to work.

The same happens when i assign it to an XML in AS3. It doesn´t work.

Please help me. It´s taking so many time.

Thanks!!

TOPICS
ActionScript
1.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 06, 2009 Oct 06, 2009

The xml you show is malformed.

The node <nivel nombre='A2'> is not closed, nor is its child <item/> node.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 06, 2009 Oct 06, 2009

First, just like Raymond said, your XML is broken, you need to fix the PHP code that generates it. Second, I've read about this problem before on some forum (I think it was the ultrashock forum) and the thing is this is not a malfunction or anything (as I can remember), it is supposed to be this way... your php generates an XML file but it will still be in php form... there is a way around this, but you need to fix it from your php code so that it would generate true XML file... as I can recall, you can do that from your .htaccess file. I'll try to get you the fix, meanwhile use google maybe you'll find something.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 06, 2009 Oct 06, 2009

there you go... http://www.ultrashock.com/forums/xml/mini-tutorial-dynamic-xml-64006.html

read this thread, I'm sure it's going to help you out

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 06, 2009 Oct 06, 2009

Thanks a lot for the help, guys.

Well. I think i had problems trying to copy the xml here. That´s why it´s broken.... but i don´t find the problem, though, there...

Let me post here another example on how is it now. It´s got the header, and the <?xml tag.

<root>
<item>
<nivel>A1</nivel>
<id>0</id>
<nombre>audio1</nombre>
<tipo>audio</tipo>
<descargable>si</descargable>
<url>../multimedia/Audios/A1_audio1.MP3</url>
</item>
<item>
<nivel>A2</nivel>
<id>1</id>
<nombre>leccion1</nombre>
<tipo>texto</tipo>
<descargable>si</descargable>
<url>../multimedia/Textos/A2_leccion1.pdf</url>
</item>
<item>
<nivel>A2</nivel>
<id>2</id>
<nombre>leccion1</nombre>
<tipo>texto</tipo>
<descargable>no</descargable>
<url>
../multimedia/Textos/no_descargable/A2_leccion1.pdf
</url>
</item>
<item>
<nivel>A2</nivel>
<id>3</id>
<nombre>audio1</nombre>
<tipo>audio</tipo>
<descargable>si</descargable>
<url>../multimedia/Audios/A2_audio1.MP3</url>
</item>
<item>
<nivel>A2</nivel>
<id>4</id>
<nombre>audio1</nombre>
<tipo>audio</tipo>
<descargable>no</descargable>
<url>../multimedia/Audios/no_descargable/A2_audio1.MP3</url>
</item>
<item>
<nivel>A3</nivel>
<id>5</id>
<nombre>esFolleto2009</nombre>
<tipo>texto</tipo>
<descargable>si</descargable>
<url>../multimedia/Textos/A3_esFolleto2009-2010.pdf</url>
</item>
<item>
<nivel>A3</nivel>
<id>6</id>
<nombre>leccion1</nombre>
<tipo>texto</tipo>
<descargable>no</descargable>
<url>
../multimedia/Textos/no_descargable/A3_leccion1.pdf
</url>
</item>
<item>
<nivel>A3</nivel>
<id>7</id>
<nombre>Avicena</nombre>
<tipo>video</tipo>
<descargable>si</descargable>
<url>../multimedia/Videos/A3_Avicena.flv</url>
</item>
<item>
<nivel>B1</nivel>
<id>8</id>
<nombre>audio1</nombre>
<tipo>audio</tipo>
<descargable>si</descargable>
<url>../multimedia/Audios/B1_audio1.MP3</url>
</item>
<item>
<nivel>B1</nivel>
<id>9</id>
<nombre>audio1</nombre>
<tipo>audio</tipo>
<descargable>no</descargable>
<url>../multimedia/Audios/no_descargable/B1_audio1.MP3</url>
</item>
</root>

...

well. maybe i fixed it ... lol... but i think it won´t work.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 06, 2009 Oct 06, 2009

That xml is fine.

If I understand your original post, you are seeing the PHP code, rather than the xml. Your code example contains a trace statement, which implies you are running the swf in the flash IDE. If that's the case, how would the PHP code be executed?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 06, 2009 Oct 06, 2009

mmm. This answer sounds interesting.

That´s my problem. Is php code executed?. I understand i have to tell actionscript to load an url, and then assign a Complete event to see the data.

But the data is NOT an xml file.

But i get this from the tutorials. This doesn´t make sense for me...

Do you know the answer?

mmm maybe... should i execute the php without loading so it generates the xml file... and then read it??... that will make conflicts!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 06, 2009 Oct 06, 2009

>>mmm maybe... should i execute the php without loading so it generates the xml file... and then read it??... that will make conflicts!

I think Raymond had the answer. PHP is executed by your server. When you go to a .php page online you don't see the .php code - because the server executes any php on the page before it serves the page. If your php generates xml you will see only the output xml online... so, you need to upload the php, and then read it from there - not from a local file.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 06, 2009 Oct 06, 2009

I know about that. But thanks for the explanation.

I know about php executed. Of course. But i have an Apache server working here, localhost executing php, and i work in local.

i tried it online , but didn´t work.

When i try to "trace" it, it drops the php text. Just don´t execute anything! Does URLLoader or URLRequest execute it??

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 06, 2009 Oct 06, 2009
LATEST

oh shit. Sorry...

it´s WORKING. Online. It works.

So i fixed it after the changes you told me, but... but the urls weren´t working in Local, but online it WORKS!

fantastic!!

Thanks a lot, and sorry about this mess.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines