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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T12:37:17+00:00 2026-05-31T12:37:17+00:00

I have an xml as <?xml version=1.0 encoding=UTF-8?> <Batch checksum=4f4e96dc724aa38965a75121b654a49830fc6a46f927f1b1803cdd22a40f1e27> <UpdateCache incremental=false cleanCache=true> <PayLoad>

  • 0

I have an xml as

<?xml version="1.0" encoding="UTF-8"?>
<Batch checksum="4f4e96dc724aa38965a75121b654a49830fc6a46f927f1b1803cdd22a40f1e27">
<UpdateCache incremental="false" cleanCache="true">
    <PayLoad>
        <ConfigurationChangeSet />
        <CacheContent Type="ReportingServices" Name="ReportingServices-conf.xml" Path="roles/ReportingServices" EntryName="ReportingServices" EntryId="175">
            &lt;RPTSVC role:instanceID="765002" role:roleName="ReportingServices" role:Identity="175"&gt;
            &lt;SSRSServerDetails&gt;
            &lt;SSRS_PORT&gt;29283&lt;/SSRS_PORT&gt;
            &lt;SSRS_SSL_PORT&gt;29284&lt;/SSRS_SSL_PORT&gt;
        </CacheContent>
    </PayLoad>
</UpdateCache>

I am working on a project that uses stax to strip up the content of the tag into a seperate file. The issue is that the stax parser is only able to strip out ‘<‘ when it encounter < and then reports it as done.

Here is the code I am using :

while(reader.hasNext()){
        XMLEvent event = reader.nextEvent();
        if(event.isStartElement()){
            StartElement startElement = event.asStartElement();

            if(startElement.getName().getLocalPart().equals("CacheContent")){
                XMLEvent cacheContentXmlEvent = reader.peek();
                if(cacheContentXmlEvent.isCharacters()){
                    Characters cacheContentXmlText = cacheContentXmlEvent.asCharacters();

                    System.out.println(String.format("Cache Content ==> %s " , cacheContentXmlText.getData())) ;
                }
            }
        }
    }

What am I doing wrong? Thanks for your help.


Here is the new code(may not be bug free yet)

while(reader.hasNext()){
        XMLEvent event = reader.nextEvent();
        if(event.isStartElement()){
            StartElement startElement = event.asStartElement();
            if(startElement.getName().getLocalPart().equals("CacheContent")){

                XMLEvent cacheContentXmlEvent = reader.peek();
                if(cacheContentXmlEvent.isCharacters()){
                    StringBuilder stringBuilder = new StringBuilder();
                    while(reader.hasNext()){
                        XMLEvent xmlCharEvent = reader.nextEvent();
                        if(xmlCharEvent.isCharacters()){
                            stringBuilder.append(xmlCharEvent.asCharacters().getData());
                        }
                        if(reader.peek().isCharacters()){
                            continue;
                        }else{
                            break;
                        }
                    }
                    System.out.println(stringBuilder.toString());
                }
            }
        }
    }
  • 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-31T12:37:18+00:00Added an answer on May 31, 2026 at 12:37 pm

    There can be multiple text nodes under a given parent. You’ll probably find that if you loop and keep checking isCharacters() that you’ll get all the text eventually.

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

Sidebar

Related Questions

I have an XML file that looks like <?xml version='1.0' encoding='UTF-8'?> <root> <node name=foo1
I have the following simplified XML: <?xml version="1.0" encoding="UTF-8" ?> <MATMAS05> <IDOC BEGIN="1"> <E1MARAM
I have the following simplified XML structure: <?xml version="1.0" encoding="UTF-8" ?> <INVOIC02> <IDOC BEGIN="1">
I have this XML at http://localhost/file.xml : <?xml version=1.0 encoding=utf-8?> <val:Root xmlns:val=http://www.hw-group.com/XMLSchema/ste/values.xsd> <Agent> <Version>2.0.3</Version>
I have the following XML <?xml version=1.0 encoding=ISO-8859-1 ?> - <DEVICEMESSAGES> <VERSION xml=1 checksum=
I have XML shaped like the following: <?xml version=1.0 encoding=UTF-8?> <feed xmlns=http://www.w3.org/2005/Atom xmlns:openSearch=http://a9.com/-/spec/opensearch/1.1/ xmlns:docs=http://schemas.google.com/docs/2007
xml version 1.0 encoding utf-8 in php, I have tried : echo '<?xml version=1.0
I have an xml like <?xml version='1.0' encoding='UTF-8'?> <feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearch/1.1/' xmlns:docs='http://schemas.google.com/docs/2007' xmlns:batch='http://schemas.google.com/gdata/batch' xmlns:gd='http://schemas.google.com/g/2005'
I have the following XML: <?xml version='1.0' encoding='UTF-8' ?> <feed xmlns='http://www.w3.org/2005/Atom' xmlns:media='http://search.yahoo.com/mrss/' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:gd='http://schemas.google.com/g/2005'
have an xml file like this. <?xml version =1.0 encoding =utf-8?> <menu> <menuNode title=Register

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.