how to extract only the ID Selector names and Class Selector names from a CSS file using java Program?
Printable View
how to extract only the ID Selector names and Class Selector names from a CSS file using java Program?
Post sample lines from the file and highlight the section of the lines that you want to extract.
.bodmas {
font-family: arial;
}
#himas {
background-color:#CCC;
border: 1px solid;
color:#39F;
text-align: center;
}
.tab {
background-color: #F60;
border: 1px solid #39F;
width: 100%;
}
#dth {
border: 0px;
text-align: center;
}
#p {
color:#09F;
text-indent: 20px;
}
#one.two
{
color: red;
}
.three.four
{
color:black;
}
Now i want to Extract the class selectors [.bodmas ,, .tab] and ID selectors [#himas, #dth] and want to list out using iterator in java....
Need Output like..,
List of Class Selectors :
1. bodmas
2. tab
etc..,
List of ID Selectors :
1. himas
2. dth
etc..,
Since CSS is a formal language, in all likelihood Java parsers for this type of task already exist. I would Google for them and then use them, rather than try to re-invent that which has already been well invented.