ȸ¿ø°¡ÀԡžÆÀ̵ð/ºñ¹øã±â
ȨÀ¸·Î


php - >xml »ý¼ºÇÏ´Â class
12³â Àü
---------------------------<XmlWriter.php>----------------------------------

<?php

// Simon Willison, 16th April 2003
// Based on Lars Marius Garshol\'s Python XMLWriter class
// See http://www.xml.com/pub/a/2003/04/09/py-xml.html

class XmlWriter {
    var $xml;
    var $indent;
    var $stack = array();
    function XmlWriter($indent = \'  \') {
        $this->indent = $indent;
        $this->xml = \'<?xml version="1.0" encoding="utf-8"?>\'."\\n";
    }
    function _indent() {
        for ($i = 0, $j = count($this->stack); $i < $j; $i++) {
            $this->xml .= $this->indent;
        }
    }
    function push($element, $attributes = array()) {
        $this->_indent();
        $this->xml .= \'<\'.$element;
        foreach ($attributes as $key => $value) {
            $this->xml .= \' \'.$key.\'="\'.htmlentities($value).\'"\';
        }
        $this->xml .= ">\\n";
        $this->stack[] = $element;
    }
    function element($element, $content, $attributes = array()) {
        $this->_indent();
        $this->xml .= \'<\'.$element;
        foreach ($attributes as $key => $value) {
            $this->xml .= \' \'.$key.\'="\'.htmlentities($value).\'"\';
        }
        $this->xml .= \'>\'.htmlentities($content).\'</\'.$element.\'>\'."\\n";
    }
    function emptyelement($element, $attributes = array()) {
        $this->_indent();
        $this->xml .= \'<\'.$element;
        foreach ($attributes as $key => $value) {
            $this->xml .= \' \'.$key.\'="\'.htmlentities($value).\'"\';
        }
        $this->xml .= " />\\n";
    }
    function pop() {
        $element = array_pop($this->stack);
        $this->_indent();
        $this->xml .= "</$element>\\n";
    }
    function getXml() {
        return $this->xml;
    }
}

/* Test

$xml = new XmlWriter();
$array = array(
    array(\'monkey\', \'banana\', \'Jim\'),
    array(\'hamster\', \'apples\', \'Kola\'),
    array(\'turtle\', \'beans\', \'Berty\'),
);

$xml->push(\'zoo\');
foreach ($array as $animal) {
    $xml->push(\'animal\', array(\'species\' => $animal[0]));
    $xml->element(\'name\', $animal[2]);
    $xml->element(\'food\', $animal[1]);
    $xml->pop();
}
$xml->pop();

print $xml->getXml();

*/
?>  
-------------------------¿¹¹®---------------------
<?php header(\'Content-Type: text/xml\'); ?><?phpinclude(\'XmlWriter.php\');$xml = new XmlWriter();$array = array(    array(\'monkey\', \'banana\', \'Jim\'),    array(\'hamster\', \'apples\', \'Kola\'),    array(\'turtle\', \'beans\', \'Berty\'),);
$xml->push(\'zoo\');foreach ($array as $animal) {    $xml->push(\'animal\', array(\'species\' => $animal[0]));    $xml->element(\'name\', $animal[2]);    $xml->element(\'food\', $animal[1]);    $xml->pop();}$xml->pop();
print $xml->getXml();
?>
------------------------------°á°ú---------------------------
<?xml version="1.0" encoding="utf-8"?>
<zoo>
  <animal species="monkey">
    <name>Jim</name>
    <food>banana</food>
  </animal>
  <animal species="hamster">
    <name>Kola</name>
    <food>apples</food>
  </animal>
  <animal species="turtle">
    <name>Berty</name>
    <food>beans</food>
  </animal>
</zoo>

ÃßõÃßõ : 631 Ãßõ ¸ñ·Ï
¹øÈ£ Á¦¸ñ
245
CSS Intro
244
CSS¿ë¾î Á¤¸®
243
±¹³»IP Á¤º¸ Á¶È¸Çϴ Ŭ·¡½º(php)
php->xml »ý¼ºÇÏ´Â class
241
socketÀÌ¿ëÇÑ Å¸»çÀÌÆ® À̹ÌÁö Àбâ
240
»çÀÌÁî°¡ Å«À̹ÌÁö À¥ÆäÀÌÁö Ãâ·Â½Ã ÀÚµ¿À¸·Î »çÀÌÁî ÁÙÀ̱â...
239
ƯÁ¤ÇÑ ´ÞÀÇ »ýÀÏÀÎ »ç¶÷ ¸®½ºÆ® °¡Á®¿À±â
238
PHP¿Í AjaxÀ» ÀÌ¿ëÇؼ­ µ¥ÀÌÅÍ Ã³¸®Çϱâ
237
ÆÄÀÏÀ» ¹«Á¶°Ç ´Ù¿î·Îµå ½ÃÅ°±â
236
include()¿ë À¥°æ·Î -> »ó´ë°æ·Î º¯È¯ ÇÔ¼ö
235
ºü¸¥ ÇÁ·Î¼¼¼­¸¦ À§ÇÑ ÄÚµù½ºÅ¸ÀÏ
234
¿¢¼¿(*.xls) È­ÀÏÀ» PHP¿¡¼­ Àбâ
233
ÆÄÀÏ ´Ù¿î·Îµå ÇÔ¼ö(¸ÖƼ À̾î¹Þ±â/¼ÓµµÁ¦ÇÑ)
232
Áֹεî·Ï ¹øÈ£·Î ³ªÀÌ ±¸Çϱâ
231
cURLÀ» ÀÌ¿ëÇÑ À¥ÆäÀÌÁö °¡Á®¿À±â
230
ÃÖ´ë°ø¾à¼ö ±¸Çϱâ (À¯Å¬¸®µå ¾Ë°í¸®Áò)
229
¼Ò¼öÀÎÁö È®ÀÎÇϱâ (À¯Å¬¸®µå ¾Ë°í¸®Áò)
228
¹®ÀÚ¿­À» X·Î ¸¶Å·ÇÏ´Â ÇÔ¼ö
227
ÆÄÀÏ ´Ù¿î·Îµå2 (Çì´õ ÀÌ¿ë)
226
ÀԷ¹ÞÀº IPÁÖ¼Ò¸¦ 127.0.¡Ù.1 ÇüÅ·Π¹Ù²Þ.
225
DBÀÇ ¹«ÇÑÄ«Å×°í¸® °¡Á®¿À±â
224
¾î¶² °æ·Î·Î Çؼ­ ÀÌ È¨¿¡ ¿À°Ô µÆ´ÂÁö ¾Ë¾Æ³»´Â ¹æ¹ý
223
Ç×»ó »õ·Î°íħ ÇØ´õ ¼³Á¤
222
Ç×»ó Çѱ۷Π³ª¿Àµµ·Ï ÇØ´õ¼³Á¤
221
PHP·Î ÀÛµ¿ÇÏ´Â RSS Àд ÇÔ¼ö
220
Ç÷¡½Ã ÆÄÀÏ Á¤º¸ ¾ò¾î¿À´Â ¼Ò½º(PHP)
219
¹®ÀÚ¿­À» X·Î ¸¶Å·ÇÏ´Â ÇÔ¼ö
218
¸ÖƼ ÆÄÀÏ ¾÷·Îµå ¿¹Á¦ (Flex2+PHP)
217
Flex 2 ¿Í PHP+MYSQL ¿¬µ¿ ¿¹Á¦
216
DB ³»¿ë ¿¢¼¿·Î »Ì¾Æ¿À±â ( ÆÄ¿öÆ÷ÀÎÆ®, MS ¿öµå°¡´É )
¸ñ·Ï
¹ÂÁ÷Æ®·ÎÆ® ºÎ»ê±¤¿ª½Ã ºÎ»êÁø±¸ °¡¾ßµ¿ ¤Ó °³ÀÎÁ¤º¸Ãë±Þ¹æħ
Copyright ¨Ï musictrot All rights reserved.