#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2013
    Posts
    2
    Rep Power
    0

    Problems reading XML


    Hi guys, I'm dealing with this problem for like a week.

    I have a csv file with a lot of links to xml's webpages, in this moment I can read all the csv file and read every xml website... BUT, when I try to reach a specific part inside the xml i just keep getting errors...
    This is the code I have so far

    import urllib2
    from xml.etree import ElementTree as et

    newsFile = 'newspaper.csv'
    file = open(newsFile, "rb")
    news = []

    for line in file.xreadlines():
    news.append(line.strip())

    for url in news:
    file = urllib2.urlopen(url)
    data = file.read()
    file.close()

    newXML = entry.find("title")

    print entry.atrrib

    I don't mind if you give a solution using beatifulsoup, dom or elementTree...

    Thanks...
  2. #2
  3. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,995
    Rep Power
    481
    The solution written in SolveAll:
    Code:
    do it
    [code]Code tags[/code] are essential for python code and Makefiles!
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2013
    Posts
    2
    Rep Power
    0
    Originally Posted by b49P23TIvg
    The solution written in SolveAll:
    Code:
    do it
    Very helpful your answer... You are making this forum a nice place to stay...
    I just want a guide, not a code... THANKS
  6. #4
  7. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2005
    Posts
    620
    Rep Power
    65
    You may want to pick just one URL to familiarize yourself with xml.etree

    The python docs have some good examples.
    Last edited by Dietrich; December 7th, 2013 at 03:33 PM.
    Real Programmers always confuse Christmas and Halloween because Oct31 == Dec25
  8. #5
  9. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,995
    Rep Power
    481
    I disagree,
    Originally Posted by ShokanPrince
    I don't mind if you give a solution using beatifulsoup, dom or elementTree...
    You don't care in which language to get a solution.

    Nor have you asked an answerable question.
    Originally Posted by ShokanPrince
    I can read all the csv file and read every xml website... BUT, when I try to reach a specific part inside the xml i just keep getting errors...
    Which web site? Which errors? Which specific part?

    And by the way, I toned down my first answer significantly from

    Solution in GOD:
    Code:
    create
    [code]Code tags[/code] are essential for python code and Makefiles!

IMN logo majestic logo threadwatch logo seochat tools logo