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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:52:22+00:00 2026-05-31T03:52:22+00:00

I have a text file that has many records. Each record is a xml

  • 0

I have a text file that has many records. Each record is a xml element. each record is separated by a text – RECORD_BREAK.

Ex

<customer><name>John</name><phone>123-345-1123</phone></customer>
RECORD_BREAK
<customer><name>John</name><phone>123-345-1123</phone></customer>
RECORD_BREAK
<customer><name>John</name><phone>123-345-1123</phone></customer>
RECORD_BREAK
<customer><name>John</name><phone>123-345-1123</phone></customer>
RECORD_BREAK

while reading the records, i split the each record by

String[] strings = xml.split(“RECORD_BREAK”);

now i need to add a Header and Footer for the file. This is to identify the file is not corrupted. how to read the header and footer of the file. Header and footer is as simple as

<CustomerInfo>
<customer><name>John</name><phone>123-345-1123</phone></customer>
RECORD_BREAK
<customer><name>John</name><phone>123-345-1123</phone></customer>
RECORD_BREAK
 </CustomerInfo> 

how can i check for the and tag at starting and ending of records before i split the records.

  • 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-31T03:52:24+00:00Added an answer on May 31, 2026 at 3:52 am

    Ideally, you would not have the RECORD_BREAK markers in the file, because you do not need them: You already have records separated by tags. Just parse the whole thing with an XML parser (especially easy after wrapping it into a top-level CustomerInfo tag).

    This also gives you at least the same very modest level of “corruption check” that your header and footer would provide, and would not fail if some customer happens to be named “Little Bobby Tables RECORD_BREAK”.

    You can still parse the file as it is now (with RECORD_BREAK in it) using an XML parser. If the header does not match the footer, it will not be valid XML and the parser will tell you (it will also tell you about malformed Customer tag contents). The result will be a nice sequence of Customer nodes and text nodes (the record breaks).

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

Sidebar

Related Questions

I have a file that has many xml-like elements such as this one: <document
I have a program that imports a text file that has many entrys: ###
What if you have a big text file that has many entries in it
Scenario: I have a text file that has pipe (as in the | character)
I have a rather large text file that has a bunch of missing newlines,
I have a text file that I want to edit using Java. It has
I have a simple WPF (XAML) file that has some animated shapes and text.
i have a java ee project which has a text file that uses a
I have Text file that contains data separated with a comma , . How
I have a text file that has sets of text I need to extract

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.