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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:06:30+00:00 2026-06-17T17:06:30+00:00

I Got following XML from Amazon Web-Service. <aws:UrlInfoResponse> <aws:Response> <aws:OperationRequest> <aws:RequestId>8789797</aws:RequestId> </aws:OperationRequest> <aws:UrlInfoResult> <aws:Alexa>

  • 0

I Got following XML from Amazon Web-Service.

<aws:UrlInfoResponse>
    <aws:Response>
        <aws:OperationRequest>
            <aws:RequestId>8789797</aws:RequestId>
        </aws:OperationRequest>
        <aws:UrlInfoResult>
            <aws:Alexa>
                <aws:TrafficData>
                    <aws:DataUrl type="canonical">google.com/</aws:DataUrl>
                    <aws:Rank>1</aws:Rank>
                </aws:TrafficData>
            </aws:Alexa>
        </aws:UrlInfoResult>
        <aws:ResponseStatus>
            <aws:StatusCode>Success</aws:StatusCode>
        </aws:ResponseStatus>
    </aws:Response>
</aws:UrlInfoResponse>

When i try to extract the rank.

xmldoc = minidom.parse(response)
itemlist = xmldoc.getElementsByTagName('aws:Rank')[0]

xmlData=itemlist.replace('<aws:Rank>','').replace('</aws:Rank>','')
print xmlData

It give me error.

AttributeError: Element instance has no attribute 'replace'
  • 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-06-17T17:06:31+00:00Added an answer on June 17, 2026 at 5:06 pm

    The issue here is that you are trying to use replace on an XML element, which is not a list and isn’t a string, which would have the .replace().

    Since you are picking out the element (which is an Element object) by using =getElementsByTagName('aws:Rank')[0], you only have one thing to work on.

    the data that you want can be reached with:

    itemlist.firstChild.data
    

    or

    itemlist.firstChild.nodeValue
    

    (@root, you had this right, I don’t know why you got downvoted)

    Now I had some trouble parsing that XML because the namespace wasnt bound, but that wasn’t a biggie.

    what would likely be clearer is the snippet as such:

    xmldoc = minidom.parse(response)
    xmlElement = xmldoc.getElementsByTagName('aws:Rank')[0]
    xmlData = xmlElement.firstChild.nodeValue
    print xmlData
    

    But in all honesty, you will probably want to check out the info on the Element object in minidom:

    http://docs.python.org/2/library/xml.dom.html#dom-element-objects

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

Sidebar

Related Questions

Following an example for Amazon Web Service API from here I got the DataSet
(Following up on this question: Getting raw XML response from Java web service client
I got following repsonse from a Web service call, I tried to unmarshal the
I've got a little c# windows service that periodically pulls xml from a web
I got following xml code . How to get comment from that xml using
At the moment i've got the following code to get data from an xml
i've got following example xml: <entity id=1> <name>computer</name> <type>category</type> <entities> <entity id=2> <name>mac</name> <type>category</type>
I've got the following sql code: declare @x xml set @x = '<ResultBlock> <MatchSummary
I've got the following selector defined in button_selector.xml <?xml version=1.0 encoding=utf-8?> <selector xmlns:android=http://schemas.android.com/apk/res/android> <item
Use 'ant clean test' with the newest android sdk got error: build.xml:622: The following

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.