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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:55:38+00:00 2026-06-14T05:55:38+00:00

I have XML like this: (this is the soup variable) <?xml version=1.0 encoding=utf-8?> <results>

  • 0

I have XML like this: (this is the soup variable)

<?xml version="1.0" encoding="utf-8"?>
<results>
 <status code="ok">
 </status>
 <principal-list>
  <principal account-id="1013353221" has-children="false" is-hidden="false" is-primary="false" principal-id="1013353225" training-group-id="" type="user">
   <name>
    First Last
   </name>
   <login>
    first.last
   </login>
   <email>
    first.last@domain.com
   </email>
   <display-uid>
    first.last
   </display-uid>
  </principal>
  <principal account-id="1013353221" has-children="false" is-hidden="false" is-primary="false" principal-id="1115269931" training-group-id="" type="user">
   <name>
    First Last
   </name>
   <login>
    first.last
   </login>
   <email>
    first.last@domain.com
   </email>
   <display-uid>
    first.last
   </display-uid>
  </principal>
 </principal-list>
</results>

I’ve tried this code:

loginlist = [el.string for el in soup.findAll('login')]
for entry in loginlist:
    print entry

It returns:

first.last

for each of the users.

I want to also find the principal-id for the nested login

My output would look like:

`'first.last', '1013353225'`
`'first.last', '1115269931'`
  • 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-14T05:55:39+00:00Added an answer on June 14, 2026 at 5:55 am

    Look for the <principal> elements instead:

    for principal in soup.findAll('principal'):
        login = principal.find('login')
        if login is None:
            continue
        print principal['principal-id'], login.string
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have XML like this: <?xml version=1.0 encoding=UTF-8?> <viewentries timestamp=20100923T130205,90Z toplevelentries=8903> <viewentry position=1 unid=A4958CC88435D1A8422577A7004422E8
I have xml file like this <?xml version=1.0 encoding=UTF-8?> <specification xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xsi:noNamespaceSchemaLocation=file://Desktop/normal.xsd> <university> <refstr>bdvl_te_skrm_stc</refstr>
I have XML exactly like this format: <?xml version=1.0 encoding=utf-8?> <book> <chapter> <verse>This is
I have a xml like this. <?xml version=1.0 encoding=utf-8 ?> <Category ID=1 AICategoryName=Schedule K:
i have xml document like this: <?xml version=1.0 encoding=utf-8 ?> <demographics> <country id=1 value=USA>
I have a XML Like this: <?xml version=1.0 encoding=utf-8?> <soap:Envelope xmlns:soap=http://www.w3.org/2003/05/soap-envelope xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xmlns:xsd=http://www.w3.org/2001/XMLSchema> <soap:Body>
I have an XML like this :: <?xml version=1.0 encoding=utf-8 ?> <Rows> <Row Id=1>
I have xml like this: <?xml version=1.0 encoding=utf-8?> <session xmlns=http://winscp.net/schema/session/1.0 name=blah@blah.com start=2011-10-03T15:09:30.481Z> <ls> <destination
I have an XML like this: <?xml version=1.0 encoding=UTF-8?> <Section> <Chapter> <Cell colname=1> <Value>A</Value>
In my XDocument variable, I have XML like this <?xml version=1.0?><bases><base id=1 type=1/><base id=2

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.