Generate XML with namespace URI in PHP

后端 未结 2 914
长情又很酷
长情又很酷 2021-01-15 13:30

Ho to make this \"simple\" xml with php using DOM? Full code will be welcomed.



        
2条回答
  •  一个人的身影
    2021-01-15 13:56

    If you want "simple" then use SimpleXML, not DOM. Note that SimpleXML won't indent the XML.

    $rss = simplexml_load_string('');
    
    $channel  = $rss->addChild('channel');
    $items    = $channel->addChild('items');
    $sometags = $items->addChild('sometags');
    $status   = $items->addChild('status', null, 'http://url.com');
    
    echo $rss->asXML();
    

提交回复
热议问题