SORU
28 Ocak 2009, ÇARŞAMBA


Nasıl XML oluşturmak dinamik olarak PHP kullanarak dosya?

Ben dinamik olarak bir xml dosyası oluşturmak için çalışma zamanı. Lütfen aşağıda XML oluşturmada bana dinamik olarak PHP kullanarak bir Yardım dosyası.

<?xml version="1.0" encoding="UTF-8"?>
<xml>
 <track>
     <path>song1.mp3</path>
     <title>Track 1 - Track Title</title>
 </track>
 <track>
     <path>song2.mp3</path>
     <title>Track 2 - Track Title</title>
 </track>
 <track>
     <path>song3.mp3</path>
     <title>Track 3 - Track Title</title>
 </track>
 <track>
     <path>song4.mp3</path>
     <title>Track 4 - Track Title</title>
 </track>
 <track>
     <path>song5.mp3</path>
     <title>Track 5 - Track Title</title>
 </track>
 <track>
     <path>song6.mp3</path>
     <title>Track 6 - Track Title</title>
 </track>
 <track>
     <path>song7.mp3</path>
     <title>Track 7 - Track Title</title>
 </track>
 <track>
     <path>song8.mp3</path>
     <title>Track 8 - Track Title</title>
 </track>

CEVAP
28 Ocak 2009, ÇARŞAMBA


SimpleXMLElement kullanmak istiyorum.

<?php

$xml = new SimpleXMLElement('<xml/>');

for ($i = 1; $i <= 8;   $i) {
    $track = $xml->addChild('track');
    $track->addChild('path', "song$i.mp3");
    $track->addChild('title', "Track $i - Track Title");
}

Header('Content-type: text/xml');
print($xml->asXML());

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Blendtec

    Blendtec

    30 EKİM 2006
  • MofoHifi Records

    MofoHifi Rec

    15 HAZİRAN 2006
  • The Amazing Atheist

    The Amazing

    20 Kasım 2006