?
Solved

How can i remove all <summary> tags and the comments inside them?

Posted on 2010-08-24
6
Medium Priority
?
411 Views
Last Modified: 2013-11-27
I want to remove all the <summary> tags including the content inside them in a class file.

So if i want to remove all the following with one operation

<summary>
blablabla
</summary>

How can i do this?
0
Comment
Question by:Norush
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 53

Expert Comment

by:Dhaest
ID: 33509682
Why would you like to do that ?

I don't know any way then to do it manually, or create another program, that reads the classfile, and removes the tags with a regexp.

Example: http://dotnetperls.com/remove-html-tags
0
 
LVL 42

Expert Comment

by:sedgwick
ID: 33509746
can u post a sample class file with summary tag for testing?
0
 
LVL 42

Expert Comment

by:sedgwick
ID: 33509927
here's a vbs that does that.

change CLASSES_FILES_FOLDER  to the folder where the classes files with the summaries you wish to remove.
it will detect c# files and vb.net files and remove all summaries from functions, properties and classes.
const CLASSES_FILES_FOLDER = "c:\temp\files"

set fso = createobject("scripting.filesystemobject")
Set objFolder = fso.GetFolder(CLASSES_FILES_FOLDER)
For Each objFile In objFolder.Files
	token = ""
	select case fso.GetExtensionName(objFile)
		case "cs": token = "///"
		case "vb": token = "'''"
	end select
	
	if token <> "" then
		RemoveSummary objFile.Path, token
	end if
 Next

 
 sub RemoveSummary(filename, token)
	
	set objSrcFile = fso.OpenTextFile(filename, 1)
	data = ""
	match = false
	Do Until objSrcFile.AtEndOfStream
		strLine = objSrcFile.Readline
		if InStr(strLine, token & " <summary>") > 0  then
			match = true
		else 
			if match = true then
				if InStr(strLine, token) = 0 then
					match = false
					data = data & strLine & vbNewLine
				end if
			else
				data = data & strLine & vbNewLine
			end if
		end if
	Loop
	
	objSrcFile.Close
	
	set objOutFile = fso.CreateTextFile(filename & "_", 2)
	objOutFile.Write data
	objOutFile.Close
 end sub

Open in new window

0
Create CentOS 7 Newton Packstack Running Keystone

A bug was filed against RDO for the installation of Keystone v3. This guide is designed to walk you through the configuration for using Keystone v3 with Packstack. You will accomplish this using various repos and the Answers file.

 
LVL 42

Accepted Solution

by:
sedgwick earned 1000 total points
ID: 33510126
made  a mistake in the script, here's the working one:
const CLASSES_FILES_FOLDER = "c:\temp\files"

set fso = createobject("scripting.filesystemobject")
Set objFolder = fso.GetFolder(CLASSES_FILES_FOLDER)
For Each objFile In objFolder.Files
	token = ""
	select case fso.GetExtensionName(objFile)
		case "cs": token = "///"
		case "vb": token = "'''"
	end select
	
	if token <> "" then
		RemoveSummary objFile.Path, token
	end if
 Next

 
 sub RemoveSummary(filename, token)
	
	set objSrcFile = fso.OpenTextFile(filename, 1)
	data = ""
	match = false
	Do Until objSrcFile.AtEndOfStream
		strLine = objSrcFile.Readline
		if InStr(strLine, token & " <summary>") > 0  then
			match = true
		else 
			if match = true then
				if InStr(strLine, token) = 0 then
					match = false
					data = data & strLine & vbNewLine
				end if
			else
				data = data & strLine & vbNewLine
			end if
		end if
	Loop
	
	objSrcFile.Close
	
	set objOutFile = fso.CreateTextFile(filename, 2)
	objOutFile.Write data
	objOutFile.Close
 end sub

Open in new window

0
 
LVL 7

Author Closing Comment

by:Norush
ID: 33511575
Thanks alot !
0
 
LVL 7

Author Comment

by:Norush
ID: 33524068
Could have wrote that on my own actualy :)

Did manage to rebuild this into a Visual Studio Maco and attach it to a custom toolbar.

Now its integrated in my VS :)
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question