Solved

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

Posted on 2010-08-24
6
404 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
  • 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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 42

Accepted Solution

by:
sedgwick earned 250 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

706 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now