This document discusses an individual's progress in a mentoring program run by Baabtra-Mentoring Partner. It includes a summary of their typing speed over 4 weeks, details of 3 jobs they have applied to, information about XML parsing in Python using SAX and DOM APIs, and contact details for Baabtra.
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
Xml passing in python
1.
2. Disclaimer: This presentation is prepared
by trainees of baabtra as a part of
mentoring program. This is not official
document of baabtra –Mentoring Partner
Baabtra-Mentoring Partner is the mentoring division of baabte System
Technologies Pvt . Ltd
5. XML parsing in python
●
Shameena
●
shameenavayoli@gmail.com
●
www.facebook.com/shameenalatheef
●
twitter.com/shameena
●
in.linkedin.com/in/shamean
●
9567135569
6. What is xml?
→ extensible markup language
→ it is portable
XML Parser Architectures and APIs
→ T he two most basic and broadly used
APIs to XML data are the SAX and DOM
interfaces.
7. Simple API for XML (SAX) :
→ T his is useful when your documents are larg e or
you have memorylimitations
→ SAX is read-only
Parsing XML with SAX APIs:
→ SAX is a standard interface for event-driven XML parsing
→requires you tocreate your own
subclassing xml.sax.ContentHandler.
ContentHandler
by
→ T he methods startDocument and endDocument are called
at the start and the end of the XML file
●
●
8. → T he ContentHandler is called at the start and end
of each element.
The parse Method:
xml.sax.parse( xmlfile, contenthandler[,
errorhandler])
→ xmlfile:T his is the name of the XML file to read
from
→ contenthandler: This must be a ContentHandler
object
→ errorhandler: If specified, errorhandler must be a
SAX ErrorHandler object.
●
●
●
9. Parsing XML with DOM APIs
→ The Document Object Model, or "DOM," is a
cross-language API from the World Wide Web
Consortium(W3C) for accessing and modifying XML
documents.
→ The DOM is extremely useful for randomaccess applications
→Easiest way to quickly load an XML document
and to create a minidom object using the xml
10. from lxml import etree
from StringIO import StringIO
def parseXML(xmlFile):
f = open(xmlFile)
xml = f.read()
f.close()
tree= etree.parse(StringIO(xml))
print tree.docinfo.doctype
c=etree.iterparse(StringIO(xml)'''
c = etree.iterparse(xmlFile) # other method
for action,entry in c:
text = entry.text
print entry.tag + " => " + text
if __name__ == "__main__":
parseXML('movie.xml')
11. If this presentation helped you, please
visit our page facebook.com/baabtra and
like it.
Thanks in advance.
www.baabtra.com | www.massbaab.com |
www.baabte.com
12. Contact Us
Emarald Mall (Big
Bazar Building)
Mavoor Road,
Kozhikode,
Kerala, India.
Ph: + 91 – 495 40 25
550
Start up Village
Eranakulam,
Kerala, India.
Email:
info@baabtra.com
NC Complex,
Near Bus
Stand
Mukkam,
Kozhikode,
Kerala, India.
Ph: + 91 –
495 40 25
550