File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes Read css Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Read css" Watch "Read css" New topic
Author

Read css

Gerenne Vives
Ranch Hand

Joined: Feb 05, 2005
Posts: 60
Hi all,

I have a file html, and this file is converted to XML with Tidy because I want read this document with DOM, but my problem is that this files contain css code too:

<styles>
......
......
</styles>

<body>
...
...
</body>

There are any form to extract the style code?

Thanks in advance!
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 7552
    
  18

Gerenne Vives wrote:There are any form to extract the style code?

Well, as far as I know, DOM allows you pull, traverse, skip or remove any section between named tags, so I suggest you give the API a good read. I also found this tutorial from IBM, who are usually pretty good, but I can't vouch for it personally. Otherwise, there's this one, or the Oracle one.

Winston


Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
Tess Jacobs
Ranch Hand

Joined: Feb 07, 2012
Posts: 66
    
    3
I tend to use Microsoft Word macros a lot when dealing with HTML documents. If you don't know how to use Microsoft Word macros, you can use Microsoft Word's Find and Replace instead.

Find \<style*\/style\> and replace with nothing. This will delete all of the <style> elements in your HTML document. Remember to check the "Use Wildcards" box before running Find and Replace.

You can also use TextPad or any other text editor that understands REGEX.

P.S.
I'm assuming that your HTML document contains the <style> element and not <styles>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Read css
 
Similar Threads
trouble loading css
There are no rules in this stylesheet
locating a file
Setting the path of servlet and jsp pages
using jsp to allow a customizable look and feel GUI