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

Add option to supress xml declaration (snippet-mode?) #55

Closed
mmangione opened this issue Mar 21, 2014 · 3 comments
Closed

Add option to supress xml declaration (snippet-mode?) #55

mmangione opened this issue Mar 21, 2014 · 3 comments

Comments

@mmangione
Copy link

This module does a marvelous job of parsing and unparsing XML. However, when I unparse an ordereddict, I do not always need the version and encoding declaration.

For example, I am creating OrderedDicts from scratch and passing them to unparse. Since these are intended to be snippets instead of fully declared xml, I find myself manually postprocessing this to remove this declaration.

@martinblech
Copy link
Owner

That's sounds like a nice feature, thanks. I will give it some thought as of how to implement it.

martinblech added a commit that referenced this issue Apr 16, 2014
If false, it suppresses the XML declaration, as required by #55.
martinblech added a commit that referenced this issue Apr 16, 2014
If false, it suppresses the XML declaration, as required by #55.
@megahall
Copy link

megahall commented Jan 6, 2015

FYI I think I found a bug in this. If you pass something like so:

{
    "@name": "dbl-test",
    "description": "dbl-test",
    "recurring": {
        "hourly": {
            "at": "00"
        }
    },
    "type": "ip",
    "url": "http://192.168.1.6:8080/pa-dbl.txt"
}

It's not able to turn that into an "XML snippet" even when you have full_document=False.

@martinblech
Copy link
Owner

@megahall I think it's not a bug: you cannot have a XML document with more than one root node. You should wrap that dict inside another dict with a single key:

{
    "root": {
        "@name": "dbl-test",
        "description": "dbl-test",
        "recurring": {
            "hourly": {
                "at": "00"
            }
        },
        "type": "ip",
        "url": "http://192.168.1.6:8080/pa-dbl.txt"
    }
}

Otherwise, what XML opening tag should the @name attribute belong to?

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

3 participants