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 4232776
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T02:08:16+00:00 2026-05-21T02:08:16+00:00

I am trying to use the shrink the web service for site thumbnails. They

  • 0

I am trying to use the shrink the web service for site thumbnails. They have a API that returns XML telling you if the site thumbnail can be created. I am trying to use ElementTree to parse the xml, but not sure how to get to the information I need. Here is a example of the XML response:

<?xml version="1.0" encoding="UTF-8"?> 
<stw:ThumbnailResponse xmlns:stw="http://www.shrinktheweb.com/doc/stwresponse.xsd">
    <stw:Response>
        <stw:ThumbnailResult>
            <stw:Thumbnail Exists="false"></stw:Thumbnail>
            <stw:Thumbnail Verified="false">fix_and_retry</stw:Thumbnail>
        </stw:ThumbnailResult>
        <stw:ResponseStatus>
            <stw:StatusCode>Blank Detected</stw:StatusCode>
        </stw:ResponseStatus>
        <stw:ResponseTimestamp>
            <stw:StatusCode></stw:StatusCode>
        </stw:ResponseTimestamp>
        <stw:ResponseCode>
            <stw:StatusCode></stw:StatusCode>
        </stw:ResponseCode>
        <stw:CategoryCode>
            <stw:StatusCode>none</stw:StatusCode>
        </stw:CategoryCode>
        <stw:Quota_Remaining>
            <stw:StatusCode>1</stw:StatusCode>
        </stw:Quota_Remaining>
    </stw:Response>
</stw:ThumbnailResponse>

I need to get the “stw:StatusCode”. If I try to do a find on “stw:StatusCode” I get a “expected path separator” syntax error. Is there a way to just get the status code?

  • 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-21T02:08:17+00:00Added an answer on May 21, 2026 at 2:08 am

    Grrr namespaces ….try this:

    STW_PREFIX = "{http://www.shrinktheweb.com/doc/stwresponse.xsd}"
    

    (see line 2 of your sample XML)

    Then when you want a tag like stw:StatusCode, use STW_PREFIX + "StatusCode"

    Update: That XML response isn’t the most brilliant design. It’s not possible to guess from your single example whether there can be more than 1 2nd-level node. Note that each 3rd-level node has a “StatusCode” child. Here is some rough-and-ready code that shows you (1) why you need that STW_PREFIX caper (2) an extract of the usable info.

    import xml.etree.cElementTree as et
    def showtag(elem):
        return repr(elem.tag.rsplit("}")[1])
    def showtext(elem):
        return None if elem.text is None else repr(elem.text.strip())
    root = et.fromstring(xml_response) # xml_response is your input string
    print repr(root.tag) # see exactly what tag is in the element
    for child in root[0]:
        print showtag(child), showtext(child)
        for gc in child:
            print "...", showtag(gc), showtext(gc), gc.attrib
    

    Result:

    '{http://www.shrinktheweb.com/doc/stwresponse.xsd}ThumbnailResponse'
    'ThumbnailResult' ''
    ... 'Thumbnail' None {'Exists': 'false'}
    ... 'Thumbnail' 'fix_and_retry' {'Verified': 'false'}
    'ResponseStatus' ''
    ... 'StatusCode' 'Blank Detected' {}
    'ResponseTimestamp' ''
    ... 'StatusCode' None {}
    'ResponseCode' ''
    ... 'StatusCode' None {}
    'CategoryCode' ''
    ... 'StatusCode' 'none' {}
    'Quota_Remaining' ''
    ... 'StatusCode' '1' {}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm trying use facebook API to upload photo in my fan page. I downloaded
I am trying use gem tire to search in my application. I have tables
I'm trying use mod_rewrite to rewrite URLs from the following: http://www.site.com/one-two-file.php to http://www.site.com/one/two/file.php The
Hi I'm trying use a datepicker on a field I have. I'm trying to
trying to use hibernate with my web app and getting following exception: Initial SessionFactory
I have been trying use the edit_post_link() function to contain an image. All of
I'm currently trying to use Quicksand, a jquery plugin that allows you to animate
I have a scenario that I've been trying to figure out through any means
I am trying to use simple grow/shrink animation using Teecharts on Android. I cant
I am trying to shrink my database log file. I have tried to run:

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.