Created
December 31, 2017 05:51
-
-
Save DineshDevaraj/3cfc012e54ff6f60adfa9c192a98e813 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import sys | |
from xml.dom import minidom | |
def PrintXml(root, pad) : | |
sys.stdout.write("\n%s%s : " % (' '*pad, root.tagName)) | |
for child in root.childNodes : | |
if isinstance(child, minidom.Text) : | |
if child.data[0] != "\n" : | |
sys.stdout.write("%s" % child.data) | |
else : | |
PrintXml(child, pad+3) | |
dom = minidom.parse('sample.xml') | |
PrintXml(dom.documentElement, 3) | |
print("\n") | |
--------------------------------------------------------------- | |
import sys | |
from xml.dom import minidom | |
def PrintXml (root, pad) : # { | |
sys.stdout.write("\n%s%s : " % (' '*pad, root.tagName)) | |
for child in root.childNodes : # { | |
if isinstance(child, minidom.Text) : # { | |
if child.data[0] != "\n" : # { | |
sys.stdout.write("%s" % child.data) | |
# } | |
# } | |
else : # { | |
PrintXml(child, pad+3) | |
# } | |
# } | |
# } | |
dom = minidom.parse('sample.xml') | |
PrintXml(dom.documentElement, 3) | |
print("\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment