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

Chaining #13

Merged
merged 2 commits into from
Jul 18, 2020
Merged

Chaining #13

merged 2 commits into from
Jul 18, 2020

Conversation

skjiisa
Copy link
Contributor

@skjiisa skjiisa commented Jul 11, 2020

Allow addAttribute and addChild calls to be chained to XML objects. This allows XML objects to be created without needing to define any variables.

Example:

You can generate the XML

<rss version="2.0">
    <channel>
        <title>Example Title</title>
        <description>Example Description</description>
        <item>
            <title>Episode 0</title>
        </item>
    </channel>
</rss>

in a single go:

XML(name: "rss")
    .addAttribute(name: "version", value: "2.0")
    .addChildren([
        XML(name: "channel").addChildren([
            XML(name: "title", value: "Example Title"),
            XML(name: "description", value: "Example Description"),
            XML(name: "item").addChildren([
                XML(name: "title", value: "Episode 0")
            ])
        ])
    ])

skjiisa added 2 commits July 10, 2020 00:03
Update the Construct XML section of the README to demonstrate chaining and XML's initializer.
@chenyunguiMilook
Copy link
Owner

Thanks for your contribution! 👍

@chenyunguiMilook chenyunguiMilook merged commit fa7a359 into chenyunguiMilook:master Jul 18, 2020
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