473,413 Members | 1,733 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

read css rule value from svg

1
Hi,

I would like to know how to read a value of a property in a css class from svg using javascript.

Specifically, I would like to retrieve the font-size of the text element in the following example.

This example includes two files: svg file, and a css file that the svg file refers to.

Thanks,
vn1977

//*********************svg file*******************************
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" standalone="no"?>
  2. <?xml-stylesheet href="commonMap.css" type="text/css"?>
  3. <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
  4.  
  5. <svg id="mainMap" width="950" height="475" 
  6.      viewBox="-82.049332 -30.5758 0.667485000000013 0.471659000000002" 
  7.       xmlns:xlink="http://www.w3.org/1999/xlink">
  8.  
  9.     <script language="text/ecmascript"  >
  10.     <![CDATA[                                
  11.     ]]>
  12.   </script>
  13. <text x="="-81.9332 " y="-30.2758" 
  14.        class ="FreewayText" >
  15.     Hello, out there
  16.   </text>
  17. </svg>
  18.  
//*******************end of svg file*************************

================================================== =
//*****************commonMap.css file***************************************
Expand|Select|Wrap|Line Numbers
  1. *.FreewayText
  2. {
  3.       text-anchor: middle;
  4.       font-family:Verdana;
  5.       font-size: 0.001;
  6.       color: black;
  7. }
//***************end of css file********************************
Oct 25 '07 #1
1 1354
acoder
16,027 Expert Mod 8TB
Welcome to TSDN!

I have no real experience with svg, but should your text element not have an id?

If it does, you can try:
Expand|Select|Wrap|Line Numbers
  1. document.getElementById("text element id").fontSize
Oct 25 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

75
by: Greg McIntyre | last post by:
I have a Python snippet: f = open("blah.txt", "r") while True: c = f.read(1) if c == '': break # EOF # ... work on c Is some way to make this code more compact and simple? It's a bit...
3
by: Yahoo | last post by:
GO TO http://sourceforge.net/projects/sdsre/ TO GET THE LATEST VERSION!!! SRE (Simple Rule Engine) is a lightweight forward chaining inference rule engine for .NET. Its 'simple' because of the...
5
by: Mitchell S. Honnert | last post by:
Is there a way, given the full path of a folder on a network, that one can programatically tell if you have Read access to that folder? I have an application where the user is able to select a...
6
by: Samuel M. Smith | last post by:
I have been playing around with a subclass of dict wrt a recipe for setting dict items using attribute syntax. The dict class has some read only attributes that generate an exception if I try to...
2
by: Tim Johnson | last post by:
I'm having trouble understanding this part of the expression evaluation rules ('6.5 Expressions', second item, C99 spec; the C++ wording is presumably identical): What precisely does the...
8
by: markjerz | last post by:
Hi, I basically have two tables with the same structure. One is an archive of the other (backup). I want to essentially insert the data in to the other. I use: INSERT INTO table ( column,...
2
by: sk.rasheedfarhan | last post by:
Hi , I have to extract a xml file line by line. Here is my xml Step1: <category name= "name" guid="{guid}"state="enabled"> Step2: <rules> Step3: <rule name="rule name" guid="{guid}"...
6
by: Lighter | last post by:
How to read "The lvalue-to-rvalue, array-to-pointer, and function-to- pointer standard conversionsare not applied to the left expressions"? In 5.18 Comma operator of the C++ standard, there is a...
1
by: MLH | last post by:
Anyone remember if A97 append query failure would ever report data breaking validation rule when such was not the case. I have an old SQL statement - several years old now. I've encountered a case...
1
by: greyseal96 | last post by:
Hi, I am a pretty new programmer, so I apologize in andvance if this is a dumb question... In a book that I'm reading to learn C#, it says that when using a foreach() loop, a read-only copy of...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.