Read CSS in VB.net code

S

steve

Is there an object that I can instantiate to read a CSS? We have some
webpages that we build dynamically in VB.net code and apply such things as
color, background color, font etc. to directly in the code. I would like to
be able to read a CSS and pull out what I need from that. Is there a way to
do this?


Thanks!
Steve
 
A

Anthony Merante

i dont think there is but it'd be nice if there was one (hint, hint)!

Can you use XML to define those css style rules?
 
C

Cor Ligthert [MVP]

Steve,

As you can write a file, than in my opinion can you as well always read a
fill. What is it we miss?

Cor
 
S

steve

I was wondering if there were a way to read a CSS via code using an object.
I know I can parse it out myself, but that's open to a lot of errors. I was
hoping there were some way to instantiate an object, open the CSS with it
and then gain access to a collection of styles or something like that.
 
Joined
Sep 27, 2006
Messages
1
Reaction score
0
Reading CSS Programmatically

Hey, I stumbled on to this thread today while I was researching how to parse a CSS file. I found a solution, so I thought I'd share it with you.

I am using VB.NET and Windows Forms. I have an MS browser control on my form, in which I load a document. Once the document is loaded, I can access the stylesheet and each of the styles, as shown in the function below. I still have some work to do, to parse out the properties in each tag, but that should be easy work. I figured this was worth sharing.

Private Function readStyleSheet()
Dim objStyleSheet As Object = browser.Document.stylesheets.item(0)
Dim objStyleSheetRules As Object = objStyleSheet.rules
Dim objstylesheetrule As Object
Dim lngStyleSheetRulesLength As Long

Dim strSelector As String
Dim strCSSText As String

With objStyleSheetRules
lngStyleSheetRulesLength = .length()

For i As Long = 0 To lngStyleSheetRulesLength
strCSSText = LCase(.item(i).style.csstext())
strSelector = LCase(.item(i).selectorText())
Next
End With
End Function
 
Joined
Apr 30, 2008
Messages
2
Reaction score
0
reading css dynamically

Hi,

I'm also in need of reading css programatically through VB.net in asp.net. and write to the css.
so please anybody provide me a good solution.

Thanks in advance.

Regards
Pradeep




steve said:
Is there an object that I can instantiate to read a CSS? We have some
webpages that we build dynamically in VB.net code and apply such things as
color, background color, font etc. to directly in the code. I would like to
be able to read a CSS and pull out what I need from that. Is there a way to
do this?


Thanks!
Steve
 
Joined
Apr 30, 2008
Messages
2
Reaction score
0
reading css dynamically

Hi,

I'm in need of reading css programatically through VB.net in asp.net. and write to the css.
so please anybody provide me a good solution.

Thanks in advance.

Regards
Pradeep
 
Joined
Aug 10, 2010
Messages
1
Reaction score
0
> I would like to be able to read a CSS and pull out what I need from that.

I have developed and released a CSS parser: see "www dot modeltext dot com slash css" for details.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,079
Messages
2,570,574
Members
47,205
Latest member
ElwoodDurh

Latest Threads

Top