Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > How To Parse HTML Page in ASPX Page

Reply
Thread Tools

How To Parse HTML Page in ASPX Page

 
 
Axel Dahmen
Guest
Posts: n/a
 
      07-29-2005
Hi,

in order to add user dependant style sheets to my HTML pages I'd like to
create an ASPX wrapper page which reads an HTML page, adds a currently
selected style sheet and then outputs the rest of the page.

But I couldn't find any class helping me to read HTML as a string enabling
me to parse it and to search in it for the header section to inject my style
element. Using HttpWebRequest seems quite awkward to me.

Can someone please enlighten me on how this can be done? Plus I don't want
to assume a particular encoding to my HTML pages. The method supposed should
have no problems with varying HTML encoding (UTF8 etc.).

TIA!
Axel Dahmen


 
Reply With Quote
 
 
 
 
Phillip Ian
Guest
Posts: n/a
 
      07-29-2005
I haven't tried this, so I'm not sure it would work, but couldn't you
use an aspx page to return the CSS? Something like

<LINK href="http://yourdomain.com/getCSSforUser.aspx?id=15"
type=text/css rel=stylesheet>

Then return a CSS file isntead of a page, much like one would use an
aspx page to return a jpg image from a database?

That way, your pages stay constant...no need to inject stuff on the
fly.

Just a thought.

-Phil

 
Reply With Quote
 
 
 
 
Axel Dahmen
Guest
Posts: n/a
 
      07-30-2005
Well, Phil, you've brought me to an idea! Tnx!

Yet there's one thing still being on my mind... I want editors (members of
the staff) to create HTML pages. Each of these HTML pages must contain the
same "fringe" mark-up, i.e. header and footer (like "Return to Homepage").
But I don't want to rely on the editors to add this "must-have" mark-up. I'd
prefer to have this more or less static addition being done automatically on
rendering. But I can't have them create .aspx pages because they don't have
the right software.

My idea was to have them create a "root" document just containing their
content and then to add all the necessary navigation stuff by ASP.NET.

Do you perhaps have an idea on that?

TIA!
Best regards,
Axel Dahmen


-----------------
"Phillip Ian" <(E-Mail Removed)> schrieb im Newsbeitrag
news:(E-Mail Removed) oups.com...
> I haven't tried this, so I'm not sure it would work, but couldn't you
> use an aspx page to return the CSS? Something like
>
> <LINK href="http://yourdomain.com/getCSSforUser.aspx?id=15"
> type=text/css rel=stylesheet>
>
> Then return a CSS file isntead of a page, much like one would use an
> aspx page to return a jpg image from a database?
>
> That way, your pages stay constant...no need to inject stuff on the
> fly.
>
> Just a thought.
>
> -Phil
>



 
Reply With Quote
 
Joerg Jooss
Guest
Posts: n/a
 
      07-31-2005
Axel Dahmen wrote:

> Hi,
>
> in order to add user dependant style sheets to my HTML pages I'd like
> to create an ASPX wrapper page which reads an HTML page, adds a
> currently selected style sheet and then outputs the rest of the page.
>
> But I couldn't find any class helping me to read HTML as a string
> enabling me to parse it and to search in it for the header section to
> inject my style element. Using HttpWebRequest seems quite awkward to
> me.


There are at least two solutions I know of: Chris Lovett's SgmlReader
on GotDotNet, and the HTML agility pack. Google for either of them.

> Can someone please enlighten me on how this can be done? Plus I don't
> want to assume a particular encoding to my HTML pages. The method
> supposed should have no problems with varying HTML encoding (UTF8
> etc.).


That's not always possible. Some sites give no indication of what
encoding is to be used whatsoever, so all that you can do is guess --
though ISO-8859-1 is a good educated guess

Cheers,
--
http://www.joergjooss.de
(E-Mail Removed)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Loading an aspx page in a fram from another aspx page =?Utf-8?B?Uk1M?= ASP .Net 1 09-16-2005 01:21 PM
adding main.aspx.vb & main.aspx.resx under aspx John M ASP .Net 1 05-29-2005 09:27 PM
How to Pass values between from a popup page aspx & a normal page aspx Marco Antonio Montalvo Durán ASP .Net 2 01-23-2004 09:35 PM
include other aspx/html in my aspx page Mr. x ASP .Net 1 11-30-2003 11:56 PM
How do I post data from aspx page to another aspx page. Sriram Mallajyosula ASP .Net 1 11-05-2003 04:48 PM



Advertisments