xmldiff

Download/Install

  1. 目的:2つのXMLの差分を列挙する。
  2. 言語:python
  3. Download
  4. install (window用)
    • サイトからダウンロードする
    • minGWをインストール
    • PATHにC:\MinGW; C:\MinGW\binを追加する。
    • python setup.py install build --compiler=mingw32
    • 私の場合、compileで失敗したが、xmldiff-0.6.10\build\lib.win32-2.7フォルダにxmldiffというフォルダが作成された。
    • このxmldiffフォルダを\Python27\Lib\site-packagesにコピーする。
    • 使うとき、from xmldiff import *

APIの使い方

sample code:

from input import * # From the xmldiff directory
from fmes import * # From the xmldiff directory
from format import * # From the xmldiff directory
from StringIO import *

# Build your original tree
text1 = '<point><x>1</x><y>2</y><z>3</z></point>'
stream1 = StringIO(text)
tree1 = tree_from_stream(stream)

# Build your modified tree
text2 = '<point><x>2</x><y>2</y><z>3</z></point>'
stream2 = StringIO(text2)
tree2 = tree_from_stream(stream2)

# Compare the trees
formatter = InternalPrinter()
corrector = FmesCorrector(formatter)
corrector.process_trees(tree, tree2)

## OUTPUT: 
## Instructions for modifying original to modified
# [rename, /point[1]/y[1], x]
# [insert-after, /point[1]/x[2],
# <y>
# 2
# </y>
# ]
# [remove, /point[1]/x[1]]



Comments