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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:44:44+00:00 2026-06-12T01:44:44+00:00

Need to parse a text file into a specific xml format.(file is a huge

  • 0

Need to parse a text file into a specific xml format.(file is a huge one millions of line and looks like this)

ABC-DATA-FILE-VERSION: 2.0

OBJFILE:    /home/abc/src/solaris/abc.o

TIMESTAMP: 1348314377 727216

SRCFILE:    /home/abc/src/solaris/abc.C

    167 7
    170 7
    174 0
    179 0
    174 0
    192 7
    196 7
    199 7
    215 0

OBJFILE:    /home/abcd/src/solaris/abcd.o

TIMESTAMP: 1348314377 727216

SRCFILE:    /home/abcd/src/solaris/abcd.C

    58  7
    65  7
    66  7
    67  7
    69  0
    79  0
    84  0
    97  14
    100 7
    108 14
    110 7
    115 14

OBJFILE:    /home/abcd/src/solaris/xyz.o

TIMESTAMP: 1348314377 727216

SRCFILE:    /home/abcd/src/solaris/xyz.C

    978   0
    979   1
    993   0
    996   0
    997   0
    1011  0
    1003  0
    1004  0
    1011  0

Now i wanted to convert it to a specific xml file format. like

<packages>
    <package name="com" line-rate="0.45161290322580644" branch-rate="0.4915254237288136" complexity="3.391891891891892">
        <classes>
            <class branch-rate="0" complexity="0" filename="/home/abcd/src/solaris/abcd.C" line-rate="0.25" name="TestRunnerModel">
                <methods/>
                <lines>
                    <line number="13" hits="1" branch="true"/>
                    <line number="14" hits="1" branch="true"/>
                    <line number="15" hits="1" branch="false"/>
                    <line number="12" hits="0" branch="false"/>
                </lines>
            </class>
            <class branch-rate="0" complexity="0" filename="/home/abcd/src/solaris/abcd.C" line-rate="0.25" name="TestRunnerModel">
                <methods/>
                <lines>
                    <line number="13" hits="1" branch="true"/>
                    <line number="14" hits="1" branch="true"/>
                    <line number="15" hits="1" branch="false"/>
                    <line number="12" hits="0" branch="false"/>
                </lines>
            </class>
            <class branch-rate="0" complexity="0" filename="/home/abcd/src/solaris/xyz.C" line-rate="0.25" name="TestRunnerModel">
                <methods/>
                <lines>
                    <line number="13" hits="1" branch="true"/>
                    <line number="14" hits="0" branch="true"/>
                    <line number="15" hits="1" branch="false"/>
                    <line number="12" hits="0" branch="false"/>
                </lines>
            </class>
        </classes>
    </package>
</packages>

Most of the xml parameters are constant only few i need to populate like

FILENAME reading from SRCFILE: /home/abcd/src/solaris/xyz.C
and

line number=”978″ hits=”0″ branch=”true”
line number=”979″ hits=”1″ branch=”false”
etc

and so on. Please help.

  • 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-12T01:44:45+00:00Added an answer on June 12, 2026 at 1:44 am

    In principle, it’s very simple. You have input in a given input format, and you’d like to produce output in a given output format. You need a parser for the input format to identify its structure and build data structures that represent that structure. And you need a serializer for your data structures that produces the XML you want.

    Parsing libraries may exist for your input format, in which case you may want to use them instead of writing your own parser from scratch. Your language may also (and probably does) have libraries for serializing things as XML; you may want to use them.

    If you know how to write a parser for a defined format, you now know what you need to do. If you don’t, you may be able to fake it with sed, awk, perl, or the batch editor of your choice, but your life as a programmer will be a lot more fun if you spend some time learning about parsing.

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

Sidebar

Related Questions

We need to parse an XML file with XSLT into a CVS file. The
I wanted to parse a text file that contains unstructured text. I need to
I need to parse some text in a UITextField and turn it into a
I need a regular expression to parse a body of text. Basically assume this
I need parse through a file and do some processing into it. The file
Need to parse a file for lines of data that start with this pattern
I am reading in a text file with tons of values in this format:
I need to translate programs written in a domain specific language into xml representation.
I'm trying to parse the content.xml inside a ODF-file. I've read the file into
I need to convert date/time in a text file into number of minutes elapsed

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.