|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
Parsing a CSS file
I've currently been tasked with parsing a CSS file. What we want to do is parse the CSS file and take the styles and place them in a Structure. For example if there's a style named .MenuTop I want to create a new Structure called MenuTop and then have the style attributes from that style placed into the related structure.
Anyone have any ideas how this can be done?
__________________
http://www.dieselstudios.com - http://www.trackmycash.com - http://www.hamptonsoftrentdale.com |
|
#2
|
|||
|
|||
|
Loops and regular expressions are probably your only option.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
|
#3
|
|||
|
|||
|
can you give me an example of what you mean?
|
|
#4
|
|||
|
|||
|
Unfortunately not. Parsing a CSS file and putting each style and the style attributes into a nested structure is going to be quite time consuming and difficult.
You could try looping over the text and try to use carriage return/line breaks as a delimiter, but that assumes that the CSS is separating the syles with line feeds. And it doesn't start to address the situations where there are multiple names for a style (like "A.bold, A#bold {....}"). I'm not saying that his will be impossible, just very hard given the possible variations in the formatting of the CSS code. |
|
#5
|
|||
|
|||
|
It wouldn't be too hard would it? because as long as you start each style definition on a new line you could split the string because of the { character. Even if you don't start on a new line you could use the } as the delimitter.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > Parsing a CSS file |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|