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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:39:24+00:00 2026-05-26T07:39:24+00:00

I have an XML file where I only care about the size attribute of

  • 0

I have an XML file where I only care about the size attribute of a certain element.
First I used

global!/<proto name="geninfo"/d

to delete all lines that I don’t care about. That leaves me a whole bunch of lines that look like this:

<proto name="geninfo" pos="0" showname="General information" size="174">

I want to delete everything but the value for “size.”
My plan was to use substitute to get rid of everything not matching ‘size=”[digit]”‘, the remove the string ‘size’ and the quotes but I can’t figure out how to substitute the negation of a string.

Any idea how to do it, or ideas on a better way to achieve this? Basically I want to end up with a file with one number (the size) per line.

  • 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-26T07:39:25+00:00Added an answer on May 26, 2026 at 7:39 am

    You can use matching groups:

    :%s/^.*size="\([0-9]*\)".*$/\1/
    

    This will replace lines that contain size="N" by just N and not touch other lines.

    Explanation: this will look for a line that contains some random characters, then somewhere the chain size=", then digits, then ", then some more random characters, then the end of the line. Now what I did is that I wrapped the digits in (escaped) parenthesis. That creates a group. In the second part of the search-and-replace command, I essentially say “I want to replace the whole line with just the contents of that first group” (referred to as \1).

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

Sidebar

Related Questions

I have a massive XML file. However, I'm only interested in a single small
I am pulling categories from an xml file. I only have 5 categories but
I'm using XmlWriterSettings to write Xml to file. I have elements with only attributes,
I have an XML file that looks like <?xml version='1.0' encoding='UTF-8'?> <root> <node name=foo1
I have an xml like file and I have to read only a part
I have an XML file in which I want to extract data from certain
Hey guys, I have an XML file I need to parse, but only for
I have an XML file that starts like this: <Elements name=Entities xmlns=XS-GenerationToolElements> I'll have
I have a XML file with data that is used in both my C#
I have an XML file with certain data which I have to convert it

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.