Disclaimer: This presentation is prepared
by trainees of baabtra as a part of
mentoring program. This is not official
docu...
Typing Speed
Week

Targ
et

Achieve
d

1

20

18

2

25

23

3

30

27

4

50

38
Jobs Applied
#

Company

Designation

Applied
Date

Current
Status

1

Skillsearch limited

Python developer

7/08/13

No ...
XML parsing in python
●

Shameena

●

shameenavayoli@gmail.com

●

www.facebook.com/shameenalatheef

●

twitter.com/shamee...
What is xml?
→ extensible markup language
→ it is portable
XML Parser Architectures and APIs
→ T he two most basic and bro...
Simple API for XML (SAX) :
→ T his is useful when your documents are larg e or
you have memorylimitations
→ SAX is read-on...
→ T he ContentHandler is called at the start and end
of each element.
The parse Method:
xml.sax.parse( xmlfile, contenthan...
Parsing XML with DOM APIs
→ The Document Object Model, or "DOM," is a
cross-language API from the World Wide Web
Consortiu...
from lxml import etree
from StringIO import StringIO
def parseXML(xmlFile):
f = open(xmlFile)
xml = f.read()
f.close()
tre...
If this presentation helped you, please
visit our page facebook.com/baabtra and
like it.

Thanks in advance. 
 
www.baabtr...
Contact Us
Emarald Mall (Big
Bazar Building)
Mavoor Road,
Kozhikode,
Kerala, India.
Ph: + 91 – 495 40 25
550

Start up Vil...
Xml passing in python
Upcoming SlideShare
Loading in …5
×

Xml passing in python

868 views

Published on

Xml passing in python

Published in: Technology, Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
868
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Xml passing in python

  1. 1. 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
  2. 2. Typing Speed Week Targ et Achieve d 1 20 18 2 25 23 3 30 27 4 50 38
  3. 3. Jobs Applied # Company Designation Applied Date Current Status 1 Skillsearch limited Python developer 7/08/13 No status 2 ioss php developer 20/08/13 Not selected 3
  4. 4. XML parsing in python ● Shameena ● shameenavayoli@gmail.com ● www.facebook.com/shameenalatheef ● twitter.com/shameena ● in.linkedin.com/in/shamean ● 9567135569
  5. 5. 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.
  6. 6. 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 ● ●
  7. 7. → 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. ● ● ●
  8. 8. 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
  9. 9. 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')
  10. 10. 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
  11. 11. 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

×