Reading CSS files in .NET.

Is there a class in .NET for reading CSS files? I think this would be equivalent to having an XmlDocument class for an XML file.

+3
source share
4 answers

It seems like it’s not there, but I managed to do what I needed by reading the entire file and doing a series or twine as follows:

} (right brace) to split individual styles

{(left bracket) to break styles into element names and style values

(comma) to split the element names up

; (semicolon) to separate styles up

: (colon) to separate style names and values

I also needed to trim the spaces, CR and LF at each step and discard blank entries to make it neat.

ListDictionary, StringDictionary .

, :

// C#
CssDocument css = new CssDocument();
css.Load("c:\mycssfile.css");
ListDictionary myBodyStyles = css["body"];  // to get all the syles for an element
string myBodyFontSize = css["body"]["font-size"];  // to get an individual style
+1

.NET Framework BCL (Base Class Library) , CSS-, - .

:

CSS Parser

+2

, .NET CSS, post, .

, CSS.

+1
0

Source: https://habr.com/ru/post/1719087/


All Articles