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

How to write xml dom to string or file #248

Open
Daniel63656 opened this issue Oct 27, 2024 · 1 comment
Open

How to write xml dom to string or file #248

Daniel63656 opened this issue Oct 27, 2024 · 1 comment

Comments

@Daniel63656
Copy link

Having written a simple xml example using the xmlWriter, how to write the dom to string or file?

 val xmlWriter = xmlStreaming.newWriter()

        xmlWriter.apply {
            startDocument("3.1", "utf-8", true)
            startTag(null, "root", null)
            attribute(null, "id", null, "123")

            startTag(null, "child", null)
            attribute(null, "name", null, "John Doe")
            text("This is a child node")
            endTag(null, "child", null)

            endTag(null, "root", null)
            endDocument()
        }
@pdvrieze
Copy link
Owner

pdvrieze commented Oct 28, 2024

Basically you want a newWriter instance that takes an Appendable parameter. For files there is the ability to specify the Writer as output.

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

No branches or pull requests

2 participants