<commit_before># Nested XML Writer

A small library providing a fluent interface to PHP's XMLWriter class.

The idea for this interface was that the combination of magic `__call` methods and anonymous functions
would allow arbitrarily nested XML to be created fluently. The result is that:

- There is only one method, the name of the element to be created;
- The common cases (element containing text, empty element, an element with children) are very simple;
- Well-formed XML is automatically output since there can be no `startElement` and `endElement` mismatches;
- Using PHP 5.4 the API is simplified further with the use of `$this` to represent the current element.

## Usage

The `NestedXMLWriter` constructor takes an XMLWriter, which will actually write the XML.

```php
# Create an in-memory XML writer (with pretty-printing)
$writer = new XMLWriter();
$writer->openMemory();
$writer->setIndent(true);
```

$xml = new NestedXMLWriter($writer);

To create an element, simply call the method of the same name:

```php
$xml->Root(); # <Root/><commit_msg>Fix code fence block.<commit_after># Nested XML Writer

A small library providing a fluent interface to PHP's XMLWriter class.

The idea for this interface was that the combination of magic `__call` methods and anonymous functions
would allow arbitrarily nested XML to be created fluently. The result is that:

- There is only one method, the name of the element to be created;
- The common cases (element containing text, empty element, an element with children) are very simple;
- Well-formed XML is automatically output since there can be no `startElement` and `endElement` mismatches;
- Using PHP 5.4 the API is simplified further with the use of `$this` to represent the current element.

## Usage

The `NestedXMLWriter` constructor takes an XMLWriter, which will actually write the XML.

```php
# Create an in-memory XML writer (with pretty-printing)
$writer = new XMLWriter();
$writer->openMemory();
$writer->setIndent(true);

$xml = new NestedXMLWriter($writer);
```

To create an element, simply call the method of the same name:

```php
$xml->Root(); # <Root/>
{'fraction_non_alphanumeric': 0.08208255159474671, 'fraction_numerical': 0.001876172607879925, 'mean_word_length': 4.780487804878049, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4451700', 'n_tokens_mistral': 576, 'n_tokens_neox': 555, 'n_words': 298}