Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
L

lib-array2xml

> 编程语言
Open source

Array2XML conversion library credit to lalit.org

309 stars0 likes0 views
WebsiteGitHub

About

Array2XML conversion library credit to lalit.org

lib-array2xml

Array2XML conversion library credit to lalit.org

Usage

php
//create XML
$xml = Array2XML::createXML('root_node_name', $php_array);
echo $xml->saveXML();

//create Array
$array = XML2Array::createArray($xml);
print_r($array);

Array2XML

@xml example:

php
// Build the array that should be transformed into a XML object.
$array = [
    'title' => 'A title',
    'body' => [
        '@xml' => '
The content for the news item
',
    ],
];

// Use the Array2XML object to transform it.
$xml = Array2XML::createXML('news', $array);
echo $xml->saveXML();

This will result in the following.

xml

  A title
  
    
      
        
The content for the news item

      
    
  

Reference

More complete references can be found here http://www.lalit.org/lab/convert-xml-to-array-in-php-xml2array/ http://www.lalit.org/lab/convert-php-array-to-xml-with-attributes/

Changelog

1.0.0

  • Add ability for callbacks during processing to check status.

0.5.1

  • Fix fata error when the array passed is empty fixed by pull request #6

0.5.0

  • add second parameter to XML2Array::createArray for DOMDocument::load, e.g: LIBXML_NOCDATA
  • change method visibility from private to protected for overloading
  • Merge pull request #5 to add child xml
  • Merge pull request #4 to change method visibility and add second parameter for load.

0.1.0

  • Initial Release

Issues· 6 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

PHP

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言