Skip to content

Generating an empty XML node with attribute. #203

Answered by weirdan
nikhil-warvatkar asked this question in Q&A
Discussion options

You must be logged in to vote

Just add attributes as you would do normally:

(new Spatie\ArrayToXml\ArrayToXml([
     'Header' => [
        '_attributes' => [
            'messageId' => '123abc-cba',
            'isTest' => 'false',
            //.......
        ],
     ],
]))->prettify()->toXml();

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
3 replies
@nikhil-warvatkar
Comment options

@weirdan
Comment options

@nikhil-warvatkar
Comment options

Answer selected by nikhil-warvatkar
Comment options

You must be logged in to vote
1 reply
@weirdan
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants