reading XML file using python

S

shanti bhushan

Hi ,
i am new to python.i want to read the XML file using python it ,by
using DOm or SAX any of them.
I want to read the http://www.google.com(any hyper text) from XML and
print that.
please give me the sample program for this.
regards
Shanti Bhushan
Bangalore,India
 
S

Stefan Behnel

shanti bhushan, 17.05.2010 10:34:
i am new to python.i want to read the XML file using python it ,by
using DOm or SAX any of them.
I want to read the http://www.google.com (any hyper text) from XML and
print that.

Note that web sites usually are HTML, not XML. Are you sure you want to
read XML as well? Also, DOM/SAX are certainly not the easiest way to
extract information from XML, use the xml.etree.ElementTree package instead.

To parse HTML from web pages, you can use several different tools in
Python, see

http://www.google.com/search?q=python+web+scraping

Stefan
 
F

Franz Kelnreiter

2010/5/17 shanti bhushan said:
Hi ,
i am new to python.i want to read the XML file using python it ,by
using DOm or SAX any of them.
I want to read the http://www.google.com(any hyper text) from XML and
print that.
please give me the sample program for this.
Hi Shanti,
The question how to read an XML file has already been answerd more
than 50 times within this group. So I fear nobody wont any longer be
willing to repeat this matter every 15 days...
Greetings,
Franz
 
S

Simon Brunning

Hi ,
i am new to python.i want to read the XML file using python it ,by
using DOm or SAX any of them.
I want to read the http://www.google.com(any hyper text) from XML and
print that.
please give me the sample program for this.

Your question isn't very clear. Do you want to read the data from a
URL (such as http://www.google.com) and parse it? If so, you probably
don't want an XML parser as such - try Beautiful Soup.

Or do you have a piece of XML with some URLs in it that you want to
extract? ElementTree in the standard library is one good choice here
if you're not wedded to one of DOM or SAX.

What have you tried so far? No one is going to write code for you, but
we'd be happy to help you fix problems with your own code.
<http://catb.org/~esr/faqs/smart-questions.html> might be worth a
read.
 
S

Stefan Behnel

superpollo, 17.05.2010 11:24:
Simon Brunning ha scritto:

btw, is there any chance that bs will be part of the stdlib anytime soon?

If someone takes over maintainership and offers support for the stdlib,
this might be worth discussing. Otherwise, no.

Stefan
 
S

Simon Brunning

Hi simon,
you are right in 2nd paragaraph.
i have a piece of XML with some URLs in it that i want to
extract.
I have no clue from where to get help on this.
Please atleast guide me for document or link where i can get such help
i can use elementary tree also but i dont know how to proceed with that.

You've not given us any idea as to the structure of your XML, so this
won't work. ;-)

import xml.etree.ElementTree as ET

for node in ET.parse('our.xml'):
print node.text

An introduction to ElementTree at <http://effbot.org/zone/element-index.htm>.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,989
Messages
2,570,207
Members
46,783
Latest member
RickeyDort

Latest Threads

Top