parse css file, extracting all classnames

Results 1 to 2 of 2

Thread: parse css file, extracting all classnames

  1. #1
    Join Date
    Dec 1969

    Default parse css file, extracting all classnames

    I need to create a listing of all classnames from any css file. Any help with the scripting for this would be much appreciated.<BR><BR>For example, if the stylesheet contains;<BR><BR>.myClass {blah...}<BR>.testClass {blah...}<BR>DIV.testClass {blah...}<BR>.blueClass {blah}<BR><BR><BR>Then, I need it to return an array containing...<BR>myClass,testClass,blueClass<BR><B R>Note how the array does not contain DIV.testClass since testClass already appears without a contextual selector<BR>

  2. #2
    Join Date
    Dec 1969

    Default This shouldn't be too hard, yet it's...

    ...not a simple task.<BR><BR>I would start with some code that takes earch line and identifies the class in that line. Once identified, it then checks whether this class has already been read, by comparing it with values stored in an array (or dictionary object?). If it doesn&#039;t exist, it adds it.<BR><BR>Then you can just write out the values stored in the array and... hey presto... you&#039;ve got it.<BR><BR>Oliver.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts