CSS Parser Component
Overview
The CSS (Cascading Style Sheet) parser takes a CSS document, converts it to an XML document and back again. Since editing XML is easier than editing CSS, this is useful when you want to programmatically edit a CSS document or build your own CSS editor. This component can be used in environments that support COM such as Active Server Pages, Windows Scripting Host, Visual Basic, etc.
- License
- Freeware
- Type
- ActiveX DLL for 32 bit OS
- Version
- 2.0
- File Name
- XCSSParser.dll
- Download Package
- x-css-parser.zip
Download
Download CSS Parser Component
Installation Instructions
- If not already installed, download and install MSXML 4 parser
- Move the dll to a directory like: C:\Program Files\XStandard\Bin\.
- Open a command prompt and
cd to the directory where the dll is located. - Type regsvr32 XCSSParser.dll
- Grant "Read & Execute" file permissions on this dll to Everyone.
Note, on Microsoft Vista, the command prompt must be "Run as administrator" as shown in the screen shot below.

Uninstall Instructions
- Open a command prompt and
cd to the directory where the dll is located. - Type regsvr32 -u XCSSParser.dll
API Reference: ProgID: XStandard.CSS2XML
Property ErrorCode As Long
(read-only)
Returns an error code if the parser failed to convert CSS to XML.
Property ErrorMessage As String
(read-only)
Returns an error message if the parser failed to convert CSS to XML.
Property Indent As Boolean
Indents the XML document for easy reading.
Sub Load(sPath As String)
Load CSS from a file.
Sub LoadCSS(sCSS As String)
Load CSS from a string.
Sub SaveAs(sPath As String, [bUnicode As Boolean = False])
Save XML to file.
Property XML As String
(read-only)
CSS data converted to XML.
API Reference: ProgID: XStandard.XML2CSS
Property CSS As String
(read-only)
XML data converted to CSS
Property ErrorCode As Long
(read-only)
Returns an error code if the parser failed to convert XML to CSS.
Property ErrorMessage As String
(read-only)
Returns an error message if the parser failed to convert XML to CSS.
Sub Load(sPath As String)
Load XML from file.
Sub LoadXML(sXML As String)
Load XML from string.
Sub SaveAs(sPath As String, [bUnicode As Boolean = False])
Save CSS to a file.
Examples
The examples below are for Active Server Pages. For Windows Scripting Host or Visual Basic, replace Server.CreateObject with CreateObject and replace Resonse.Write with MsgBox.
How to change the foreground color of an <h1> tag
<%Dim objCSS, objXML, objDoc, objNodeSet objCSS = Server.CreateObject("XStandard.CSS2XML")Set objXML = Server.CreateObject("XStandard.XML2CSS")Set objDoc = Server.CreateObject("MSXML2.DOMDocument.4.0")objDoc.async = FalseRem - Convert CSS to XMLobjCSS.LoadCSS "h1 {color:red}"Rem - Load XML into parserobjDoc.LoadXML objCSS.XMLRem - Change the colorSet objNode = objDoc.selectSingleNode("/css/rule[selector = 'h1']/declaration[property = 'color']/value")If Not objNode Is Nothing ThenobjNode.Text = "green"End IfRem - Convert XML to CSSobjXML.LoadXML objDoc.documentElement.XMLResponse.Write objXML.CSSSet objCSS = NothingSet objXML = NothingSet objDoc = NothingSet objNode = Nothing%>