Print inside tag XML

Regex, python

1. interface .bat (double click), e.g., execute.bat drill4Opseq.xml tag1 tag2 > hasil.txt

2. python script, e.g.,

# -*- coding: utf-8 -*-
from __future__ import print_function
import sys
import re

def printData(beg, en, line):    
    reg = beg + r"(.*?)" + en
    "remove whitespace @beg.of line, esp. for title"
    line = re.sub(r"^\s+", "", line)

    if, line):    
        "print substring between beg and end"
        for match in re.finditer(reg, line, re.S):
            print(, end="")
            print("\t", end="")

def main():
    i = 0
    arg = 0
    insideTag = False
    #app = QtGui.QApplication(sys.argv)
    if len(sys.argv)")
                printData("\s", "=", line)
            printData("\"", "\"",  line)

if __name__ == "__main__":

ps: pakai   buat indent 😀


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s