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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:42:16+00:00 2026-05-27T17:42:16+00:00

We have a Java project which uses JSF. In our view layer we didn’t

  • 0

We have a Java project which uses JSF. In our view layer we didn’t use ids in all our XHTML files. What I want to do is to parse XHTML files and check for tags like

<h:inputText id="username" value="#{identity.username}"/>

The constant part is <h:input...>
The rest can be anything like <h:inputSecret <h:inputWHATELSE after selecting the correct tag. I want to check if there is an id attribute of that tag. If not, I want to add an id to it.

Here is one of our XHTML files.

I tried to do the work with Python. I tried ElementTree, piksemel and BeautifulSoup. Any help about this issue will be appreciated.

  • 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-27T17:42:17+00:00Added an answer on May 27, 2026 at 5:42 pm

    Using Beautifulsoup, you could do this as follows:

    from BeautifulSoup import BeautifulSoup
    import re
    
    soup = BeautifulSoup(<your_xml_here>)
    nodes = soup.findAll(name=re.compile('^h:input'))
    for node in nodes:
        if 'id' not in dict(node.attrs):
            node['id'] = <whatever you need>
    

    As it can be seen, to get all the nodes that match the name pattern you’re looking for all you need is a regular expression. After that, you can check the node attributes to make sure if id is defined or not and assign a new value when needed.

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

Sidebar

Related Questions

i have a java ee project which has a text file that uses a
I got a Java Webapp project which uses Struts2 as the controller layer. I
I have the following usecase: I have a java project (myProj) which uses a
We have a mixed Java and Scala project, which uses Spring transaction management. We
I have a netbeans java console project which uses Spring 3.0 ( which is
I have an Android Maven project, which uses pure Java libs, I've struggled with
I have a Java project which uses platform specific libraries. They are quite large
I'm currently working on a Java project which uses Tibco rendezvous control. I have
I have a medium-sized Java project in Eclipse, which uses Vector<E> instead of the
I have a java project in which I have Referenced Libraries. In the Referenced

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.