LoginSignup
0
0

More than 5 years have passed since last update.

めざせpythonライブラリマスター (26)easyxml

Posted at

【ライブラリ説明】

 pythonでxml生成できる

【インストール注意】

 pip install -e git+git://github.com/5monkeys/easyxml.git@develop#egg=easyxml
  上記コマンドでインストールする

【プログラム】

easyxml.py
# -*- coding: utf-8 -*-

from easyxml import EasyXML

books = EasyXML('books')
books.book(title='Example A')
books.book.author(name='John Smith', age=57)
books.book.publisher(name='Publisher A')
books.book(title='Example B')
books.book.author(name='Jane Doe', age=30)
books.book.author(name='James Cutter', age=45)
books.book.publisher(name='Publisher B')
print str(books)
# <?xml version="1.0" ?><books><book title="Example A"><author age="57" name="John Smith"/><publisher name="Publisher A"/></book><book title="Example B"><author age="30" name="Jane Doe"/><author age="45" name="James Cutter"/><publisher name="Publisher B"/></book></books>

【問題】

 出力したxmlが改行されてない・・・

【参考サイト】

 pypi
 github

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0