PHP code example of maxnz / xml-builder

1. Go to this page and download the library: Download maxnz/xml-builder library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

maxnz / xml-builder example snippets


$xml = new XMLElement(
    qualifiedName: "elementName",
    value: "element value",
);

print($xml->buildXML());

$xml = new XMLElement(
    qualifiedName: "elementName",
    value: "element value",
    attributes: [
        "attribute1" => "attribute 1 value",
        "attribute2" => "attribute 2 value",
    ],
);

print($xml->buildXML());

$xml = new XMLElement(
    "elementName",
    "element value",
    [
        "attribute1" => "attribute 1 value",
        "attribute2" => "attribute 2 value",
    ],
    [
        new XMLElement(
            "child1",
            children: [
                new XMLElement(
                    "childOfChild",
                    "valueOfChild",
                )
            ]
        ),
        new XMLElement(
            "AnotherChild",
            "child2 Value",
        ),
    ],
);

print($xml->buildXML());