Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Removing Invalid Tags via ASP

Status
Not open for further replies.

derrickorama

Programmer
Jun 30, 2006
25
US
Does anybody know of a way to load an ASP page whilst removing certain tags before it's fully loaded? Example: We use certain tags that are invalid such as <Content> and such (for a content management application) and it's difficult to validate a page sometimes due to these invalid tags. They aren't going to be removed anytime soon, so I was wondering if there was a way to remove them when the ASP page loads.

Currently, to validate a site that we've developed, we need to run the page through a PHP script that I made that removes the tags using regular expressions.

I just wanted to know if there was a way to correct these invalid tags without removing them from the pages themselves. More so, to remove them when they are loaded from a browser.

Any help is appreciated.

Thanks,
Derrick
 
I'm not sure how many tags you have to remove, but you can use the Replace function and replace the tags with "".

Can you post a snippet of code, so we can see exactly how the unwanted <> tags are in your code??









[monkey][snake] <.
 
The code would look something like this:

<html>
<head>
*head tags and info*
</head>
<body>
<Content>
*content*
</Content>
</body>
</html>

I could do a search and replace if I loaded the page into a variable or something. Is there an efficient way of loading the page, but excluding certain tags? I want it so that we can properly validate our pages without removing the invalid tags. It would be awesome if I could make the pages valid via the browser and validators, but have the file actually be invalid behind the scenes. The issue is that the invalid tags are throwing off our validation process.
 
Is there an efficient way of loading the page, but excluding certain tags?

You can't load the ASP page and exclude tags. You can comment out the invalid tags with HTML or ASP, in that case, the validator won't try to validate the code inside the comment.

Let me rephrase this quote
Can you post a snippet of code, so we can see exactly how the unwanted <> tags are in your code??

Can you post a snipped of your [!]ASP[/!] code?





[monkey][snake] <.
 
How about something like this?

[tt]
<%
Dim bShowTags
bValidateMode = True
%>

<html>
<head>
*head tags and info*
</head>
<body>

<% If bValidateMode Then %>
<Content>
<% End If %>

*content*

<% If bValidateMode Then %>
</Content>
<% End If %>
</body>
</html>
[/tt]
 
Whoops the variable named in the "Dim" line is different than the one I actually used but oh well, you get the idea.
 
I was just thinking this (but I don't know how this is setup):
<html>
<head>
*head tags and info*
</head>
<body>

<!--<Content>-->
*content*

<!--</Content>-->
</body>
</html>


[monkey][snake] <.
 
Yes, that is pretty much exactly how it's set up, the only problem is that anything inside of the <Content> tags can be edited by any one of our clients. So if they log in and delete everything, the closing comment will be gone and we'll be left with:

<html>
<head>
*head tags and info*
</head>
<body>

<!--<Content>

</Content>-->
</body>
</html>

Which will end up commenting out the content. If I had control over the content management system, I would change the invalid tag into a comment (which would make sense). Unfortunately, I have to find ways to work with this invalid code generating system. My ultimate goal is to be able to spit out valid code, but actually retain the functionality between the page and the content management system (keep the invalid tags). I'm looking for a work-around until a change such as you've suggested can be made. Is there one? Or shall I give up my quest?
 
The answer is you can't.

Once the source code has left the server that is your control over it gone.

Your only option is what you are already doing with PHP or with ASP

Code:
function CTags(strIn)
	dim objRE
	set objRE = New RegExp
	objRE.pattern = "<content>|</content>" 
	objRE.Global = True
	CTags = objRE.replace(strIn,"")
	set objRE = nothing
end function


Chris.

Indifference will be the downfall of mankind, but who cares?
Woo Hoo! the cobblers kids get new shoes.
People Counting Systems

So long, and thanks for all the fish.
 
Personally my solution would be to not output the tags in the first place. If your CMS is outputting crap HTML tags then you either need to ask them to fix their stuff or you need to find a new CMS.
And a note from me to that company: if they are outputting invalid tags to the end browser and calling it HTML or XHTML then they may want to consider getting out of the web market because they obviously don't belong in this market. There is absolutely no reason to output invalid tags to the end user just because you need some sort of placemarker on the server to insert data from the CMS.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top