Created
August 10, 2011 07:05
-
-
Save bemasher/1136281 to your computer and use it in GitHub Desktop.
Go is the better structured and long-winded version. Python is the simpler and much more trouble-prone.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Person> | |
<Name>Doug</Name> | |
<Age>23</Age> | |
<YChromosone>true</YChromosone> | |
</Person> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Person> | |
<Name>Doug</Name> | |
<Age>23</Age> | |
<YChromosone>True</YChromosone> | |
</Person> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"os" | |
"fmt" | |
"xml" | |
) | |
type Person struct { | |
XMLName xml.Name `xml:"Person"` | |
Name string | |
Age int | |
YChromosone bool | |
} | |
func main() { | |
doug := Person{Name:"Doug", Age:23, YChromosone:true} | |
xml.Marshal(os.Stdout, doug) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from lxml import etree | |
from lxml.builder import E | |
xml = E.Person( | |
E.Name("Doug"), | |
E.Age("23"), | |
E.YChromosone("True") | |
) | |
print etree.tostring(xml, pretty_print=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment