Thanks martin... as you mentioned,

" As the SVG DTD defines its attributes in an external DTD you will 
not get Mozilla to look at it at all and therefore Mozilla (at least 
in not SVG enabled builds) will not know about attributes of type ID 
in SVG documents and thus getElementById does not find anything."

Is that means since i am using external DTD, therefore I couldn't use 
getElementById for my case? If so, is there anyway I can make my SVG 
DTD define its attributes "internally" so that Mozilla able to look 
at it and know about attributes of type ID in my SVG documents?

And, how about if I use other browser, such as IE? But by far, I 
tried it with IE, and error was shown and no popup (alert) window 
shown at all....

Thanks,
.S



--- In svg-developers@yahoogroups.com, "Martin Honnen" 
<[EMAIL PROTECTED]> wrote:
> 
> --- In svg-developers@yahoogroups.com, "samcctan" <[EMAIL PROTECTED]> 
wrote:
> 
> > I am writing a program to retrieve information from SVG in 
> > Javascript. 
> > I used "getElementsByTagName" and able to get the informations 
(the 
> > attributes) of a particular element. 
> > 
> > But when i use "getElementById", it doesn't work anymore. 
Although in 
> > my SVG code, there is an element with id - "xAxis", but when I 
run my 
> > Javascript which embedded in HTML in FIrefox, it indicates that 
it 
> > is "null" for my element. 
> 
> With HTML document the id attribute is defined for all elements and
> when you script HTML documents in a browser then getElementById 
looks
> for an element with the id attribute having the matching value.
> However with XML in general there is no predefined id attribute, the
> DTD of a document needs to define which attributes are of type ID 
and
> only if it does so and the DOM implementation reads the DTD then it
> knows what attributes to look for if a call to 
document.getElementById
> happens.
> If the case of SVG an attribute of type ID with name id is defined 
for
> all elements I think but that happens in the external DTD which
> Mozilla's XML parser does not read at all.
> To give you a simple example (not SVG related) check the output of
> 
> var xmlMarkup = [
>   '<gods>',
>   '  <god name="Kibo" home="http://www.kibo.com/"; />',
>   '</gods>'
> ].join('\r\n');
> 
> var DTD = [
>   '<!DOCTYPE gods [',
>   '<!ELEMENT gods (god)*>',
>   '<!ELEMENT god EMPTY>',
>   '<!ATTLIST god ',
>   '  name ID #REQUIRED',
>   '  home CDATA #IMPLIED>',
>   ']>'
> ].join('\r\n');
> 
> var domParser = new DOMParser();
> var xmlDocument1 = domParser.parseFromString(xmlMarkup,
> 'application/xml');
> var xmlDocument2 = domParser.parseFromString(DTD + '\r\n' + 
xmlMarkup,
> 'application/xml');
> 
> alert(xmlDocument1.getElementById('Kibo')); // shows null
> alert(xmlDocument2.getElementById('Kibo')); // shows Element
> 
> with Mozilla, you will find that only if the DTD defines the
> attributes of type ID with a certain name (which does not have to be
> id but can be something else like 'name' in the example) that
> getElementById is able to find elements.
> 
> As the SVG DTD defines its attributes in an external DTD you will 
not
> get Mozilla to look at it at all and therefore Mozilla (at least in
> not SVG enabled builds) will not know about attributes of type ID in
> SVG documents and thus getElementById does not find anything.
> 
> You will have to live with other tools like getElementsByTagName
(NS),
> childNodes, and XPath if you know that to access elements in an SVG
> document.





-----
To unsubscribe send a message to: [EMAIL PROTECTED]
-or-
visit http://groups.yahoo.com/group/svg-developers and click "edit my 
membership"
---- 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/svg-developers/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to