Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3361818
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T03:11:54+00:00 2026-05-18T03:11:54+00:00

I am trying to use xml.etree.ElementTree to parse responses from eBay finding API, findItemsByProduct.

  • 0

I am trying to use xml.etree.ElementTree to parse responses from eBay finding API, findItemsByProduct. After lengthy trial and error, I came up with this code which prints some data:

import urllib
from xml.etree import ElementTree as ET

appID = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
isbn = '3868731342'

namespace = '{http://www.ebay.com/marketplace/search/v1/services}'

url = 'http://svcs.ebay.com/services/search/FindingService/v1?' \
    + 'OPERATION-NAME=findItemsByProduct' \
    + '&SERVICE-VERSION=1.0.0' \
    + '&GLOBAL-ID=EBAY-DE' \
    + '&SECURITY-APPNAME=' + appID \
    + '&RESPONSE-DATA-FORMAT=XML' \
    + '&REST-PAYLOAD' \
    + '&productId.@type=ISBN&productId=' + isbn

root = ET.parse(urllib.urlopen(url)).getroot()

for parts in root:
    if parts.tag == (namespace + 'searchResult'):
        for item in list(parts):
            for a in list(item):
                if a.tag == (namespace + 'itemId'):
                    print 'itemId: ' + a.text
                if a.tag == (namespace + 'title'):
                    print 'title: ' + a.text

But that seems not very elegant, how can I get the ‘itemId’ and ‘title’ without looping over all attributes and checking if it is the one I want? I tried using things like .get(namespace + 'itemId') and .find(namespace + 'itemId') and .attrib.get(namespace + 'itemId') but nothing really worked.

Can someone maybe show me how to do this using some python wrapper for this API?
I saw easyBay, ebay-sdk-python and pyeBay but I didn’t manage to get any of them to do what I want. Is there any eBay python API which is worthwhile to use for this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T03:11:55+00:00Added an answer on May 18, 2026 at 3:11 am

    You can use ElementTree. If you want to get the items you can use findall and the path to the items, then iterate over the list of items:

    items = root.findall(namespace+'searchResult/'+namespace+'item')
    for item in items: 
         item.find(namespace+'itemId').text
         item.find(namespace+'title').text
    

    To get directly to the first itemId from the root:

    root.find(namespace+'searchResult/'+namespace+'item/'+namespace+'itemId')
    

    Basically, the find method uses XPath to retrieve elements more than one level below the subelements. See also Effbot’s explanation of XPath support in ElementTree

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use XPath to parse an XML document. One of my NSXMLElement's
I am trying to use JQuery to parse a sitemap.xml to look like this
I'm trying to use XML documentation on the members of a class, and in
I am working on an Actionscript 2 project - trying to use the XML
Trying to use an excpetion class which could provide location reference for XML parsing,
Trying to find an XML file I can use in lieu of a look-up
I trying to use ImageInfo and Jython to get information from a image on
I am trying to use XML::RAI perl module on UTF8 coded text and I
I am trying to use xml builder without explicit definition of elements. This is
I'm trying to use XML files and XSL stylesheets instead of ordinary phtml templates

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.