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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:39:23+00:00 2026-05-25T12:39:23+00:00

I have an xml document in which I use list of user nodes. Is

  • 0

I have an xml document in which I use list of user nodes.

Is there a way to do the following using StAX API?

  1. update password attribute [for change password option]
  2. add a new user node
  • 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-25T12:39:24+00:00Added an answer on May 25, 2026 at 12:39 pm

    StAX doesn’t sound like the easiest option to do what you’re asking in my opinion. However …

    The XMLStreamReader interface has a getLocation() method, so when you encounter a part of the XML String that you find interesting, you could maintain a List of actions to perform afterwards, along with the location where you should perform them.

    So in rough pseudo-code:

    while (parsing) {
        int event = xmlStreamReader.next();
        if (isEventPasswordAttribute(event)) {
            // create an Action to update password attribute,
            // passing in xmlStreamReader.getLocation() and other necessary parameters
        } else if (isTimeToAddNewUserNode(event)) {
            // create an Action to add new user
            // passing in xmlStreamReader.getLocation() and other necessary parameters
        }
    } // end parse
    
    ...
    
    for (Iterator<Action> it = actions.iterator(); it.hasNext(); ) {
        Action action = it.next();
        action.perform();
    }
    

    The Action of course needs to be passed a reference to the original XML String/Stream in order to update it. For a String this should be easy. For a Stream possibly not, as once the stream has been read the first time it may not be able to be reset(). You may have to buffer all the contents yourself as you’re performing the original parse. And you would have to be careful that the actions don’t alter the locations, otherwise subsequent Actions would look at the wrong place in the XML stream.

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

Sidebar

Related Questions

I have an XML document which contains nodes like following:- <a class=custom>test</a> <a class=xyz></a>
I have an xml document which consists of a number of the following: -
I am using MSXML3 and have loaded an xml document which is a HTML
I have a single xml document (data.xml), which I display as HTML using an
I have an XML document which looks something like this: <meadinkent> <record> <comp_div>MENSWEAR</comp_div> <sty_ret_type>ACCESSORIES</sty_ret_type>
I have got an XML document which looks something like this. <Root> <Info>....</Info> <Info>....</Info>
I have created a xslt document which formats an xml document, but I would
TASK : I have an existing xml document (UTF-8) which uses xml namespaces and
I have XML tag that has the content which is HTML document. <xml-tag> <!--
I have one xml document which I have to deserialize. The document looks something

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.