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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:43:00+00:00 2026-05-23T20:43:00+00:00

I need to parse a file .xsd in Python as i would parse an

  • 0

I need to parse a file .xsd in Python as i would parse an XML.
I am using libxml2.
I have to parse an xsd that look as follow:

<xs:complexType name="ClassType">
<xs:sequence>
    <xs:element name="IeplcHeader">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="device-number" type="xs:integer" fixed="1"/>
            </xs:sequence>
            <xs:attribute name="version" type="xs:integer" use="required" fixed="0"/>
        </xs:complexType>
    </xs:element>

when i access with

doc.xpathEval('//xs:complexType/xs:sequence/xs:element[@name="IeplcHeader"]'):

tells me that cannot find the path.

while if i remove all the xs: as follow

<complexType name="ClassType">
  <sequence>
    <element name="IeplcHeader">
        <complexType>
            <sequence>
                <element name="device-number" type="xs:integer" fixed="1"/>
            </sequence>
            <attribute name="version" type="xs:integer" use="required" fixed="0"/>
        </complexType>
    </element>

in this way it works

doc.xpathEval('//complexType/sequence/element[@name="IeplcHeader"]'):

Does anyone knows how can i get read of this problem fixing a prefix? righ now i am preparsing the file removing the xs: but it’s an orrible solution and i really hope to be able to find a better solution.

(I did not try with py-dom-xpath yet and i do not know if may work even with the xs:)

thanks,
ste

  • 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-23T20:43:02+00:00Added an answer on May 23, 2026 at 8:43 pm

    If you have to deal with xsd files, maybe also using them to validate xml files I suggest you to pass to lxml that has a good support for XMLSchema files.

    example code:

    from lxml import etree
    from cStringIO import StringIO
    
    f = StringIO()
    
    f = StringIO('''\
     <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
     <xsd:element name="a" type="AType"/>
     <xsd:complexType name="AType">
       <xsd:sequence>
         <xsd:element name="b" type="xsd:string" />
       </xsd:sequence>
     </xsd:complexType>
     </xsd:schema>
    ''')    
    
    xmlschema_doc = etree.parse(f)
    
    xmlschema_doc.xpath('xsd:element',
        namespaces={"xsd": "http://www.w3.org/2001/XMLSchema"})
    

    results in:

    [<Element {http://www.w3.org/2001/XMLSchema}element at 0x9a17f2c>]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very large XML file that I need to parse so I
I need to parse a file that contains various XML files, i.e., <xml></xml> <xml></xml>
I have the following node I need to parse using XSLT 1.0 from xml
I have an XML file that is validated against an XSD file. When a
I need to parse a DSL file using Python. A DSL file is a
Hi I need to parse XML file using jquery. I created read and display
I have 2 questions: 1-I need to parse XML file and insert the data
I need to parse a xml file which is practically an image of a
I have a rather big number of source files that I need parse and
I have an application running on multiple IIS servers that need to parse a

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.