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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:51:28+00:00 2026-05-18T01:51:28+00:00

I need to extract requests from a log file that look like this :

  • 0

I need to extract requests from a log file that look like this :

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<vehicleRegistration>
.... XML in between ....
.... XML in between ....
.... XML in between ....
.... XML in between ....
... at nth line there is line like this <vehicle id="2312313"></vehicle>
.... XML in between ....
.... XML in between ....
</vehicleRegistration>

The important issue is that vehicleRegistration can be 5 lines and sometimes 17, its changeable. It is where my current grep has failed, I used :

grep -A 13 "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" vehicle.log

Also another issue is that, sometimes a request can be sent 2 or more times because the service might be unavailable for some reason, so there might be same multiple requests in the file.

I should also rule out duplicate requests, the way to know that the request is duplicate by comparing nth line(not the last line) <vehicle id="2312313"></vehicle>, if vehicle id repeated than its a duplicate.

What is the way you would solve this? Suggestions, code, pseudo-code, anything is welcome.

EDIT :

Log file is not an xml file, its just a file containing some small percentage of xml requests and I can’t parse it as XML

EDIT II :

I extracted only the vehicle registration part, using @eugene y one line command perl -nle 'm{<vehicleRegistration>} .. m{</vehicleRegistration>} and print' logfile , how can I get rid of duplicates, those nodes that have same vehicle id, I want to keep only one copy of those.

  • 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-18T01:51:29+00:00Added an answer on May 18, 2026 at 1:51 am

    Use XPath to recover XML element nodes. There are lots of frameworks for various modern scripting languages.

    With Perl, you might do something like:

    #!/usr/bin/perl
    
    use strict;
    use warnings;
    use XML::XPath;
    
    my $file = 'vehicleRegistration.xml';
    my $xp = XML::XPath->new(filename => $file);
    
    print "Vehicle id: ".$xp->find('//vehicle/@id')."\n";
    

    If you need to, parse your log file to extract the XML document portion, and then run the XPath expression on it to recover the element and data you want.

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

Sidebar

Related Questions

I have requests in a database from which I need to extract the name
Need to extract .co.uk urls from a file with lots of entries, some .com
I have a JSON file, and i need to extract values from it and
I need to have this link: http://myserver:/myproject/innerpage/clip.jsf&id=9099 to extract the id from a code
I can't figure this out. I need to extract the second level domain from
I need to extract a value from a hidden HTML field, have somewhat figured
I need to extract the URL's from the php datas, how can i achieve
I need to extract this text: Line 1 text. Line 2 text. Line 2
I need to extract the arguments from a function Say, Function_1(arg1,agr2,....argn). Is it possible
I need to extract numbers that are longer than 3 digits and do not

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.