Created
December 31, 2017 05:51
-
-
Save DineshDevaraj/3cfc012e54ff6f60adfa9c192a98e813 to your computer and use it in GitHub Desktop.
Revisions
-
DineshDevaraj created this gist
Dec 31, 2017 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,42 @@ 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")