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

  • Home
  • SEARCH
  • 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 7885357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:02:49+00:00 2026-06-03T05:02:49+00:00

How do I generate and parse XML like the following using lxml ? <s:Envelope

  • 0

How do I generate and parse XML like the following using lxml?

<s:Envelope xmlns:s="a" xmlns:a="http_//www.w3.org/2005/08/addressing">
....
</s:Envelope>

I currently swap : with _ in the element names when I parse and generate XML, but it seems stupid.

  • 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-03T05:02:51+00:00Added an answer on June 3, 2026 at 5:02 am

    It’s not clear exactly what you’re asking, but maybe this will help:

    An element such as <s:Envelope> is using a XML namespace prefix. This is used to indicate that the s:Envelope attribute in this document is defined in the a namespace.

    LXML represents XML namespaces using a namespace prefix in braces, for example: {a}Envelope. Your example document is sort of confusing, because you also defined the a: namespace prefix, so:

    • a:Element is equivalent to {http://www.w3.org/2005/08/addressing}Element, and
    • s:Element is equivalent to {a}Element.

    Many of the LXML commands let you provide a namespace prefix mapping. For example, to find the Envelope element in your document using XPATH, you could do this:

    import lxml.etree as etree
    doc = etree.parse('mydocument.xml')
    envelope = doc.xpath('//s:Envelope',
      namespaces={'s': 'a'})
    

    Note that this is exactly equivalent to:

    envelope = doc.xpath('//x:Envelope',
      namespaces={'x': 'a'})
    

    That is, the namespace prefix doesn’t have to match what is used in the source XML document; only the the absolute namespace matters.

    You can read more about LXML and namespaces here.

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

Sidebar

Related Questions

How can I generate XML with the following schema using JAXB. <NS1:getRatesResponse xmlns:NS1="http://mynamespaceTypes"> <response>
I am using opencsv to parse text file and generate List<String[]> now I want
I'd like to parse a SOAPUI Project file and generate some documentation from the
I need to generate XML on MonoTouch application ? How i can create like
I generate a coverage.xml output file with the following command. C:\Program Files\NCover\NCover.Console.exe //reg //w
I would like to know is there any way to generate xml schema from
I am using Happy to generate a parser. I have found that when I
I'm trying to parse a string that was generated by an NSDateFormatter using another
By default, a parser generated using ANTLR-3 extends from org.antlr.runtime.Parser. How do I have
Given the following XML structure: <courses> <course> <title>foo</title> <description>bar</description> </course> ... </courses> How could

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.