Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to add processing instructions #168

Merged
merged 2 commits into from
Sep 12, 2021

Conversation

prestonholt
Copy link
Contributor

I came across this issue #143 and also needed this feature. It adds the method addProcessingInstruction($target, $data) to the ArrayToXML object and can be used like this:

$arrayToXml = new ArrayToXml($array);
$arrayToXml->addProcessingInstruction('qbxml', 'version="13.0"');
$result = $arrayToXml->toXml();

Which would generate:

<?xml version="1.0"?>
<?qbxml version="13.0"?>
<root><Good_guy><name>Luke Skywalker</name><weapon>Lightsaber</weapon></Good_guy><Bad_guy><name>Sauron</name><weapon>Evil Eye</weapon></Bad_guy></root>

Multiple processing instructions can be added, and they will always be prepended above the root element.

I figured this may not be used enough to justify adding it to the convert() method arguments, but am happy to add it there if wanted.

@prestonholt
Copy link
Contributor Author

Hey @freekmurze , just wanted to see if you had any feedback on this. Thanks!

@freekmurze
Copy link
Member

Could you rebase against master to resolve the conflicts?

@prestonholt
Copy link
Contributor Author

@freekmurze Conflicts should be resolved now

@freekmurze freekmurze merged commit aaa512f into spatie:master Sep 12, 2021
@freekmurze
Copy link
Member

Thanks!

@prestonholt prestonholt deleted the add-processing-instructions branch September 12, 2021 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants