• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Read css

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Ranch Hand
Posts: 71
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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>
 
The moustache of a titan! The ad of a flea:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic