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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:13:08+00:00 2026-06-15T02:13:08+00:00

I have this partial XML string = ”’ <x:root> <x:tag1 x:anyAttrib=anyValue x:anyAttrib=anyValue x:anyAttrib=anyValue />

  • 0

I have this partial XML

   string = ''' 
   <x:root>
       <x:tag1 x:anyAttrib="anyValue" x:anyAttrib="anyValue" x:anyAttrib="anyValue" />
       <x:tag2 x:anyAttrib="anyValue" x:anyAttrib="anyValue" x:anyAttrib="anyValue">
          someValue
       </x:tag2>
       <x:tag3> someValue
    '''

Now I would like to “stupidly” repair it.
I have thought of a way- regexing all of the start elements and ending element –> checking which element is missing and just add it. with out getting into too much of details of course.
what I’ve come with so far is (and this does not work):

import re
starts = re.compile('(?<=<)x:\w+(?=>)|(?<=<)x:\w+(?! .+ />)')
print(start.findall(string))

what I expect is a list of x:root , x:tag2 , x:tag3

I’ve been googling and trying alot but could not find an answer.
They only thing I get from this expression is x:root , x:tag1 , x:tag3.

Please help

Thanks

  • 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-15T02:13:09+00:00Added an answer on June 15, 2026 at 2:13 am

    Thanks for alexis for helping me.

    The correct expression is:

    re.findall(r'<\s*(w:\w+)[^>]*(?<!/)>', string)
    

    Using this expression, you’ll be able to extract both cases:

    first <tag>

    second <tag attrib1="value" attrib2="value" attribN="value"/>

    I tried to use some built-in python parsers with no luck, including Beautifulsoup which unfortunately did not fix the XML exactly the way I expected it to.

    Have a good one! 🙂

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

Sidebar

Related Questions

I have an XML string which contains Dates formatted dd/MM/yyyy hh:mm:ss. I'm loading this
I have the need to parse partial XML fragments (which are presented as std::string),
I have this in my partial view: <tr> <% for (int currentDay = 0;
say I have this control: public partial class bloc999 : UserControl { bloc999Data mainBlock
I have a constructor question for C#. I have this class: public partial class
I have this user defined function. public partial class UserDefinedFunctions { static int i;
Ok I have this problem I'm trying to use Jquery to load a partial
How can i dynamically load a Partial View? I mean I have this view,
I have a program that looks something like this: public partial class It {
I have a page that is setup like this public partial class _Default :

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.