Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Pretty Xml Laravel Package

simonschaufi/pretty-xml

View on GitHub
Deep Wiki
Context7

pretty-xml

A tiny library for pretty printing XML, inspired purely from DomDocument's lack of ability to configure indent distance.

Latest Stable Version Total Downloads

Usage

Installation

The recommended way to install the extension is using Composer.

Run the following command:

composer require simonschaufi/pretty-xml

How to use

Prettify

To use, give it a badly indented (but well-formed and valid) XML string:

use PrettyXml\Formatter;

$formatter = new Formatter();
echo "<pre>" . htmlspecialchars($formatter->format('<?xml version="1.0" encoding="UTF-8"?><foo><bar>Baz</bar></foo>')) . "</pre>";

You can also change the size of the indent:

$formatter->setIndentSize(2);

And you can change the indent character:

$formatter->setIndentCharacter("\t");

Minify

use PrettyXml\Formatter;

$formatter = new Formatter();
echo htmlspecialchars($formatter->minify(<<<XML
<?xml version="1.0" encoding="UTF-8"?>
<foo>
    <bar>Baz</bar>
</foo>
XML));

// keep comments
echo htmlspecialchars($formatter->minify(<<<XML
<?xml version="1.0" encoding="UTF-8"?>
<foo>
    <!-- comment -->
    <bar>Baz</bar>
</foo>
XML, true));

Thanks

Thanks to vkBeautify for their algorithm.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor