[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Problem with getElementById()


svg getelementbyid
9/24/2002 11:49:01 AM, "li, gang" <li_gang@e...> wrote:

>I want to get an element by its unique id. I set the attribute "id" to the
>element. But when I called Document.getElementById(), it returns null. I'm
>using Apache Batik DOM implementation. Does anybody ever used it? Or how to
>use it in other packages like Xerces? I looked at Xerces API, but didn't
>find any useful information.

In HTML, the attribute "id" is defined as having the ID type (in principle by
the DTD, but essentially "by magic" as far as browsers are concerned).
Since SVG does have an ID attribute called "id" on every element, I 
dont' know why Batik's DOM doesn't work for you.  Perhaps you have to
explicitly tell it what DTD you're using? Or you're not using SVG data?  
In XML generally, one needs a DTD or schema to tell the parser to tell the 
DOM implementation that a particular attribute has the ID type (and 
the name of the attribute does NOT have to be "id"). 

The DOM Level 2 spec doesn't provide a way to set the "id-ness" of an attribute,
it has to come from the DTD/Schema at parse time. 







PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.