Simple XML Document Analysis : XML Parse : XML PYTHON examples


PYTHON examples » XML » XML Parse »

 

Simple XML Document Analysis


 

import sys
from xml.parsers import expat

def start_element(name,attrs):
    print 'Start:', name, attrs

def character_data(data):
    print 'Data:', repr(data)

def end_element(name):
    print 'End: ', name

p = expat.ParserCreate()

p.StartElementHandler = start_element
p.EndElementHandler = end_element
p.CharacterDataHandler = character_data

p.ParseFile(open(sys.argv[1]))

   
  



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON examples

 Navioo XML
» XML Parse